Skip to content

Wrong 'saveSelection' #144

@dbudde

Description

@dbudde

I have found an instance of when 'saveSelection' is called, that it incorrectly saves a selection outside of the editor. You can reproduce the issue by going to (https://mindmup.github.io/bootstrap-wysiwyg/) and following these instructions.

  1. Highlight/select the text 'Go ahead'.
  2. Click on the Create Hyperlink/Anchor button.
  3. Click into the 'URL' input box placing focus on the box.
  4. Hover over the editor area, and then take the mouse cursor outside the editor onto the page.
  5. Click on the page to make the 'URL' input box lose focus and the dropdown to close.

You should see the temporary highlight stick around rather than have the selection return properly. Here is my suggested fix.

Wysiwyg.prototype.saveSelection = function() {
     var currentRange = this.getCurrentRange();
     if (typeof currentRange !== "undefined" && $.contains(this.editor[0], $(currentRange.commonAncestorContainer).parent()[0]))
     {
          this.selectedRange = this.getCurrentRange();
     }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions