-
Notifications
You must be signed in to change notification settings - Fork 4.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
Writing flow: fix horizontal caret placing for empty editable with placeholder #30463
Conversation
Size Change: +103 B (0%) Total Size: 1.42 MB
ℹ️ View Unchanged
|
Nice! This manually tests well for me, I also verified that this calculation is only run on the edges of a text range vs on any key press. It does look like there's spec failing in paragraphnav.mp4 |
@@ -12,6 +12,7 @@ export default function QueryPaginationNextEdit( { | |||
<PlainText | |||
__experimentalVersion={ 2 } | |||
tagName="a" | |||
style={ { display: 'inline-block' } } |
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 really related, but saw this when running full site editor e2e tests. Looks like the warnings are ignored so let's log an error instead.
E2e test should pass now. |
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.
Thanks for looking into this one! I tested this again with FF and tried to trigger some of the scrolling cases. Behavior here looks correct to me and E2Es are passing.
ffscroll.mp4
@@ -305,6 +305,8 @@ export function toTree( { | |||
// selection. The placeholder is also not editable after | |||
// all. | |||
contenteditable: 'false', | |||
style: | |||
'pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;', |
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.
Never ran into user-select before, TIL.
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.
Yeah, everything selection related is a bit obscure
Description
Attempts to fix #30393 (comment).
Horizontal caret placement at content editable edges by the writing flow component does not work as expected when there is a placeholder. Currently we let the browser select the field's content (which includes the placeholder) and then collapse the selection either to the start or end. This seems a bit problematic since the caret can end up after the placeholder, which is technically possible, but shouldn't be allowed. The caret cannot be placed there unless programmatically done so.
To resolve the issue, I've changed
placeCaretAtHorizontalEdge
to use the same technique asisEdge
andplaceCaretAtVerticalEdge
which is to let the browser create aRange
that is closest to a certain point. This will completely ignore the placeholder (which is non editable and disables pointer events).How has this been tested?
Create a new post. Focus the title field. Press three times Enter and two times ArrowLeft. The caret should be in the first paragraph block.
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).