Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Try another approach to fixing the sibling inserter in Firefox #7530
In #7220 we introduced a new behavior for the sibling inserter, which requires a click on the plus in the center as opposed to just clicking between two blocks.
Turns out it was sort of a race condition between onClick and onMouseDown, the latter which fires first. So in a way, the Firefox and Safari behavior of selecting the block (which is selected onMouseDown) as opposed to clicking the sibling inserter was the correct one.
This PR "fixes" it by also making the sibling inserter use onMouseDown. But in addition to this, it uses onClick as well, so it's still keyboardable.
The net effect is that both work, with the added benefit that in Firefox and Safari, the block that you're hovering isn't briefly "selected" when you're clicking.
Note, though, that when clicking, text focus isn't set on the newly created sibling block. This is something we'll want to fix before this can be merged.
This could be DRY'd up, but since I'll take a shot at getting the focus to work I'll just do that ^_^
Maybe we can add a comment clarifying why we need this duplication. Also, do you have any idea if we can replace the parent
onMouseDown event with
onClick? This could be more impactful but I wonder why we're using
onMouseDown in the first place.
Thanks for the fast review, and will look at tests in a second. Just wanted to clarify that I just pushed a change in 743c219 which changes it so the onFocusInserter is attached to onMouseDown as well, and this fixes the issue for Firefox and Safari, without us losing focus. Behold:
The issue where the block toolbar briefly appears is still there, but this is an improvement in that it now works as intended.
Edit: It's also fixed in Firefox, but I figured I'd only record one GIF.
The issues have been addressed, by yourself even :D