Skip to content

Fix: Post title caret position issue#68005

Closed
Kallyan01 wants to merge 2 commits intoWordPress:trunkfrom
Kallyan01:fix/post-title-caret
Closed

Fix: Post title caret position issue#68005
Kallyan01 wants to merge 2 commits intoWordPress:trunkfrom
Kallyan01:fix/post-title-caret

Conversation

@Kallyan01
Copy link
Copy Markdown

@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

@github-actions
Copy link
Copy Markdown

👋 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
@github-actions
Copy link
Copy Markdown

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 <kallyansin@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

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
Copy Markdown
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
@Mamaduka
Copy link
Copy Markdown
Member

Thanks for contributing, @Kallyan01!

Closing this based on the general discussion in the issue. The selection needs to be tracked by the global and not the local state. I've some ideas on how to implement it and will try to create a PR when I've some time.

@Mamaduka Mamaduka closed this Apr 25, 2025
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