-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Firefox: fix wrong text highlighting with double-click #4908
Conversation
🦋 Changeset detectedLatest commit: 246db12 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I see that the problem of integration test in:
I checked git history. That |
It's just timing out in our CI environment. We need to improve our integration tests, but I don't think it's related to your change. |
@dylans |
I've been traveling so I'm a bit behind on my reviews. I will get to it soon. |
Hey, can we merge this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 2 small suggestions, otherwise LGTM. I'm a bit worried that it will potentially break stuff in unexpected places, but in the worst case, we can revert this
options: { | ||
exactMatch: T | ||
suppressThrow: T | ||
exactMatch: boolean | ||
suppressThrow: boolean | ||
} | ||
): T extends true ? Point | null : Point { | ||
): Point | null { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge fan of the signature change, it makes sense that it returns a non-nullable value when not using suppressThrow
(although the current definition is wrong as exactMatch
should be boolean and not T
since it doesn't influence the 'nullability' of the return, as far as I can see). The same is the case for toSlateRange
.
if (IS_FIREFOX && !isCollapsed && anchorNode !== focusNode) { | ||
const isEnd = Editor.isEnd(editor, anchor, anchor.path) | ||
const isStart = Editor.isStart(editor, focus, focus.path) | ||
|
||
if (isEnd) { | ||
const after = Editor.after(editor, anchor as Point) | ||
// Editor.after() might return undefined | ||
anchor = after || anchor | ||
} | ||
|
||
if (isStart) { | ||
const before = Editor.before(editor, focus as Point) | ||
focus = before || focus | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should replace this with a Editor.hangRange
helper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the feedback within the PR.
Superseded by #5580 |
Description
Firefox had an another response of
Document.getSelection()
method. After double-clicking on a word with some mark, you can't unmark this word.Issue
Fixes: #3336 #3374
Example
Old behavior
New behavior
Context
I also changed
toSlatePoint
interface. I don't see any use and reason of this method with old generics. I tried to make a cypress test, but I can't do it. Cypress doesn't support highlighting text by double-clicking. Maybe this is not true. But I see that cypress moves the text cursor to the end of the word that was double-clicked. And I can say that the test (cypress/integration/examples/select.ts
) is not correct. Because cursor pointer is seated at the end of a paragraph after triple-clickChecks
yarn test
.yarn lint
. (Fix errors withyarn fix
.)yarn start
.)yarn changeset add
.)