Skip to content
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

Fix: Post title caret position issue #68005

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

Kallyan01
Copy link

@Kallyan01 Kallyan01 commented Dec 15, 2024

What?

See: #64724

Why?

Previously we were not maintaining any caret position history stacks so predicting caret positions on undo/redo was not possible .

How?

  • Used a history array which records the caret positions on different onChange events .
  • Captured different key strokes to listen to undo and redo events .

Testing Instructions

Testing Instructions for Keyboard

  • Add a new post or page.
  • Select the Title block and enter a title.
  • Paste additional text into the end of the field.
  • Undo the paste with Cmd+z/Ctrl+z (using the editor toolbar Undo button changes focus from the field, so is n/a).
  • Observe the location of the caret after undo ( | caret is moved to start of the deleted text).
  • Without clicking or repositioning the caret, re-paste into the field with Cmd+v/Ctrl+v.
  • Observe where the pasted text is inserted ( | text is inserted at end of field with updated caret position ).

Screenshots or screencast

Before

Screen.Recording.2024-12-16.at.4.22.47.PM.mov

After

Screen.Recording.2024-12-16.at.4.16.45.PM.mov

Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Kallyan01! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Dec 15, 2024
@Kallyan01 Kallyan01 marked this pull request as ready for review December 16, 2024 12:22
@Kallyan01 Kallyan01 requested a review from alexstine as a code owner December 16, 2024 12:22
Copy link

github-actions bot commented Dec 16, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Kallyan01 <[email protected]>
Co-authored-by: Mamaduka <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Feature] History History, undo, redo, revisions, autosave. labels Dec 16, 2024
@Mamaduka
Copy link
Member

Posted a general comment in the issue - #64724 (comment); let's continue the discussion there.

@Kallyan01, the trunk on your fork seems a bit out of sync. Do you mind rebasing this atop the lastest trunk from "upstream"?

@Kallyan01 Kallyan01 force-pushed the fix/post-title-caret branch from 9df1dd1 to 4e4d929 Compare December 16, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] History History, undo, redo, revisions, autosave. First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants