-
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
Post Title: Move selection at the end after pasting over the text #64665
Conversation
Size Change: -30 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
@ellatrix, can I get a sanity check for this proposed fix? 🙇 |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Thanks for the patch! To test in Safari, I also applied the fix from #64671, and it resolved the issue except after an Undo (Cmd+z). In this instance, after Undo, the caret appears to be at the start, but the clipboard is pasted at the end of the field. Happy to report this separately if it should be. Test ReportEnvironment
Actual Results✅ After pasting text into the title field, the caret is positioned at the end of the pasted text. Supplemental Artifacts
|
I also noticed that, and after digging, it turned out to be a general bug with the RichText component. The same behavior can be reproduced with Tagline block. Problem
Unfortunately, I don't have a solution at the moment. Let's create a separate issue for it. ScreeencastCleanShot.2024-08-22.at.07.19.31.mp4 |
774488e
to
2f55a8c
Compare
Thanks for creating a separate issue, @ironprogrammer! I'll merge this PR. |
…rdPress#64665) Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: ironprogrammer <ironprogrammer@git.wordpress.org> Co-authored-by: annezazu <annezazu@git.wordpress.org> Co-authored-by: MadtownLems <madtownlems@git.wordpress.org>
What?
Fixes #59798.
PR updates the Post Title component to collapse and move the selection at the end after pasting over the text. It matches other
RichText
components and native browser behaviors.Why?
While the component updated the internal selection state, it never adjusted the DOM selection. This is handled internally via
applySelection
, but this method was never called due to customonPaste
implementation.How?
When pasting, use the
value
andonChange
callbacks provided by theuseRichText
hook to update the text.Testing Instructions
Testing Instructions for Keyboard
Same.
Screenshots or screencast
CleanShot.2024-08-21.at.06.22.45.mp4