-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Remove focus event from RichText #44304
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -275,28 +275,11 @@ export function useInputAndSelection( props ) { | |
return; | ||
} | ||
|
||
if ( ! isSelected ) { | ||
// We know for certain that on focus, the old selection is invalid. | ||
// It will be recalculated on the next mouseup, keyup, or touchend | ||
// event. | ||
const index = undefined; | ||
|
||
record.current = { | ||
...record.current, | ||
start: index, | ||
end: index, | ||
activeFormats: EMPTY_ACTIVE_FORMATS, | ||
}; | ||
onSelectionChange( index, index ); | ||
} else { | ||
if ( isSelected ) { | ||
applyRecord( record.current ); | ||
onSelectionChange( record.current.start, record.current.end ); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It turns out, this is the only "useful" code here that doesn't duplicate |
||
|
||
// Update selection as soon as possible, which is at the next animation | ||
// frame. The event listener for selection changes may be added too late | ||
// at this point, but this focus event is still too early to calculate | ||
// the selection. | ||
rafId = defaultView.requestAnimationFrame( handleSelectionChange ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we first try to remove it without removing this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not clear to me why we need this since when "focus" happens, the selection changes so the callback is called no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just curious which of these changes makes which tests fail, so we can address it more easily. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just curious which of these changes makes which tests fail, so we can address it more easily. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just curious which of these changes makes which tests fail, so we can address it more easily. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like everything passes now that I restored that part There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say let's look into that separately then. |
||
} | ||
|
||
|
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.
The main goal for my explorations on this PR is to get rid of this, which was causing onSelectionChange to be called twice on focus, I'm assuming it's already done in the "selectionchange" event.
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.
If it's called twice, it will be called first here, then in the "selectionchange" event.