Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOM mutation observer refocuses the editor preventing Tab navigation #1404

Closed
kloots opened this issue Apr 13, 2017 · 2 comments
Closed

DOM mutation observer refocuses the editor preventing Tab navigation #1404

kloots opened this issue Apr 13, 2017 · 2 comments

Comments

@kloots
Copy link

kloots commented Apr 13, 2017

At Slack we're using the focus-ring library to style focus when the user navigates using the keyboard. The focus-ring library binds focus and blur event listeners used to add and remove a focus-ring class from the event target. Unfortunately, once you navigate into a Quill editor using the Tab key, you cannot navigate out by pressing Tab as a result of Quill re-focusing the editor in response to DOM mutation. (Specifically, Quill currently calls setNativeRange() in response to a mutation event.)

Here's the breakdown of the the sequence of events:

  1. The user presses Tab to navigate out of a Quill editor, and in response to the blur event the focus-ring library removes the focus-ring class from the editor's contenteditable <div>.
  2. The callback for the mutation observer created by Parchment's ScrollBlot is called, which in turn calls update()
  3. update() emits a 'scroll-before-update' event.
  4. Selection's 'scroll-update' listener calls setNativeRange() method.
  5. setNativeRange() focuses the editor if it doesn't already have focus

Steps for Reproduction

  1. Visit the repro example on codepen.io
  2. Use the Tab key to move from button one, to button two, then into the editor
  3. Try to use the Tab key to move from the editor to the third button

Expected behavior:

You should be able to press Tab to exit the editor.

Actual behavior:

Re-focusing the editor in response to the DOM mutation (class name removal) prevents the user from navigating out via the Tab key.

Platforms:

Chrome on Mac and Windows (and likely Linux, but wasn't able to test on Linux)

Version:

1.2.3

@kloots
Copy link
Author

kloots commented Apr 17, 2017

Thanks so much for this fix @jhchen. Can you publish this update to npm so we can pickup this fix at Slack?

@jhchen
Copy link
Member

jhchen commented Apr 17, 2017

Yes I will later today but want to get a couple other bug fixes in.

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

No branches or pull requests

2 participants