Navigating quickly down blocks can cause toolbars to flicker indefinitely
Issue Overview
Note, this is an extremely intermittent bug
When navigating quickly between blocks, gutenberg can sometimes get into a state where it keeps switching focus in a cycle between a few blocks.
Steps to Reproduce (for bugs)
- Create a new page with about ten paragraph blocks (you may need more) and fill in dummy content
- Hold down the down key from the first block until you get to the end
- If nothing chaotic happens, hold up to get back to the start, and if still nothing chaotic happens, hold down to go back to the end.
Browser: Chrome
Expected Behavior
Navigation continues normally up and down the page
Current Behavior
The navigation gets into a cycle where the focus gets trapped between a few blocks and rapidly switches between them. The toolbar, consequently, flickers up and down the page. The only way to stop it to transfer the focus. Clicking on Elements in the Chrome inspector seems to work well.
Possible Solution
This is an interaction between focus logic in TinyMCE, and how Gutenberg is focusing editors in WritingFlow keydown. We can replicate a similar problem outside of gutenberg (see Fiddle here). The solution will be handled within TinyMCE.
Related Issues and/or PRs
Todos
- [ ] Tests
- [ ] Documentation
I ran into something similar... Is this the problem?
https://www.dropbox.com/s/c0ek76t2mbi8eta/untitled.mp4?dl=0
Yep, that's the problem. It's an issue in tinymce that is surfaced by quickly opening new inline sections without removing previous ones (I think). It's not your other navigation code, as I can replicate it in that fiddle.
This should be fixed in TinyMCE 7.4.2
This has been fixed as of TinyMCE 4.7.2.