-
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
Undo in Title or Tagline block positions caret at start of field #64724
Comments
I would like to work on this issue ! |
@Kallyan01, feel free to give it a try. |
I think to solve this issue efficiently and handle all the edge cases , we need to maintain a undo , redo stack where we can store the caret position ! @Mamaduka @ironprogrammer let me know if i am thinking in the right direction ! |
@Kallyan01, the editor maintains the undo/redo stack for this data, but for block attributes, it also maintains a I think we need to store similar selection data for entity properties like Title and Tagline. |
@Mamaduka @ironprogrammer i've raised the PR #68005 , can you have a look ! |
@Kallyan01, thank you for your efforts on this! I appreciate the proposed solution, but I believe exploring a more general resolution to the issue would be beneficial. #68005 tries to resolve the issue locally for the PostTitle component by mimicking global history and keeping a local copy, which has a couple of downsides:
cc @ellatrix, @youknowriad, what do you think? Related #37171. |
Site title etc. should store selection similar to how |
I'm guessing you'd also want to introduce a |
@Mamaduka Thank you for the feedback! I understand your concerns regarding the replication of logic across multiple components and the potential divergence of global and local histories. If we want to maintain the caret logic within Gutenberg, keeping the history globally might not offer significant benefits, as those histories are specific to a single component. Thus, encapsulating the logic within each component itself seems to make sense in this context. However, an alternative approach could be to integrate this logic directly into @wordpress/rich-text via the useRichText() hook. This would centralize the behaviour and potentially reduce duplication across components. |
Description
After Undo (Cmd+z) of a paste in the Title or Tagline block, the caret is (visually) positioned at the start of the field. However, subsequently pasted text is inserted at the end of the field, which is not expected based on caret position.
Expected behavior after Undo would be for:
In testing a related issue, #64665, @Mamaduka also indicated:
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
Demonstration of pasting text and resultant caret position. After Undo of paste caret appears to be at front but pastes at the end of the field.
Environment info
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
The text was updated successfully, but these errors were encountered: