Skip to content

Use focusInline from getSelection(), not value, when blocking select#4

Open
justinweiss wants to merge 1 commit into
YurkaninRyan:masterfrom
aha-app:use-updated-focus-inline-for-onselect
Open

Use focusInline from getSelection(), not value, when blocking select#4
justinweiss wants to merge 1 commit into
YurkaninRyan:masterfrom
aha-app:use-updated-focus-inline-for-onselect

Conversation

@justinweiss
Copy link
Copy Markdown

At the time onSelect is called on a plugin, change.value.selection hasn't been updated with the new selection. Since we block onSelect based on change.value.selection.focusInline, this means that you can end up blocking selection incorrectly in the following case:

  1. Select an inline that's 3 characters long
  2. Select character 3 of any other node
  3. Watch as change.value.selection isn't updated with the new cursor position

Here's an example:

2018-05-27 at 3 40 pm

This change relies on window.getSelection() for every check, and double-checks focusInline.key, ensuring that we'll update the selection when clicking on a different node.

At the time `onSelect` is called on a plugin, `change.value.selection`
hasn't been updated with the new selection. Since we block onSelect
based on `change.value.selection.focusInline`, this means that you can
end up blocking selection incorrectly in the following case:

1. Select an inline that's 3 characters long
2. Select character 3 of any other node
3. Watch as change.value.selection isn't updated with the new cursor position

This change relies on `window.getSelection()` for every check, and
double-checks `focusInline.key`, ensuring that we'll update the
selection when clicking on a different node.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant