fix: Firefox invisible text cursor after dropping blocks #2128
+9
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR blurs the editor after blocks are dragged and dropped. This is mainly to fix an issue in Firefox that causes the text cursor to become invisible after drag & drop. However, it's also generally better for UX, as having the editor keep focus makes the formatting toolbar show up. Notion also doesn't show the toolbar after blocks are dropped.
R.e. the Firefox invisible cursor issue, this was a bit of a rabbithole.
First off, this also happens with TipTap's drag handle implementions (vanilla JS, React, and Vue):
Vanilla JS Drag Handle
React Drag Handle
Vue Drag Handle
Then I found that TinyMCE also had this issue ages ago, but was since fixed:
TinyMCE #2823
TinyMCE #1497
Unfortunately, despite searching for it, I couldn't find the PR with the fix for these issues.
There's also a ProseMirror bug report that's been open for years regarding what seems to be the same issue:
ProseMirror #593
So overall, looks like this is just a bug with Firefox, and the best we can do is work around it. Blurring the editor and refocusing it works. This PR just blurs it (as this more closely matches Notion's UX), but could be changed to refocus it after too.
Closes #2036
Rationale
The caret disappearing in Firefox is a major annoyance, and users have to click somewhere outside the editor, then back on it, to make it reappear.
Changes
Made editor DOM element get blurred at the end of
blockDragEnd.Impact
N/A
Testing
Is there even a way to test for this? Even with e2e test screenshots, the text cursor blinks so they seem like they'd be flaky at best.
Screenshots/Video
N/A
Checklist
Additional Notes