Skip to content

Fixes the cursor position when clicking on a Slate block - #8402

Open
wesleybl wants to merge 1 commit into
mainfrom
slate-pointer
Open

Fixes the cursor position when clicking on a Slate block#8402
wesleybl wants to merge 1 commit into
mainfrom
slate-pointer

Conversation

@wesleybl

Copy link
Copy Markdown
Member

On pages with many blocks, clicking on a Slate block would cause the click position to be lost, with the cursor jumping to the beginning of the text. Now, we save the position and set it on the Slate block after it is selected.

@wesleybl

Copy link
Copy Markdown
Member Author

I noticed that this is happening even when there are few blocks. Further investigation is needed. This didn't happen before.

@wesleybl
wesleybl marked this pull request as draft August 20, 2026 05:10
@wesleybl
wesleybl force-pushed the slate-pointer branch 2 times, most recently from e571f1d to 40affe7 Compare August 20, 2026 20:27
@wesleybl
wesleybl marked this pull request as ready for review August 20, 2026 20:27
@wesleybl

Copy link
Copy Markdown
Member Author

Upon closer inspection, I noticed the issue affects only a few blocks, and specifically within the /edit —not when creating new content. This problem arose after: #5273

However, the fix remains essentially the same; I’ve made some improvements and added a Cypress test.

@davisagli @sneridagh @Wagner3UB Could you take a look at this? This bug is really annoying.

@wesleybl
wesleybl requested a review from Wagner3UB August 20, 2026 20:33
@davisagli

Copy link
Copy Markdown
Member

@wesleybl How can I reproduce the issue? It seems to be working okay for me on https://demo.plone.org/edit in Firefox.

@nileshgulia1

Copy link
Copy Markdown
Member

This issue happens when you go to /edit on any page and click on a Slate block. You'll notice the cursor always jumps to the front of the block instead of where you clicked.

I reproduced this on the main branch, and also on a custom Volto 18 site, where it happens inconsistently, sometimes it occurs, sometimes it doesn't.

On main, I confirmed that this branch fixes the issue.

@nileshgulia1 nileshgulia1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm from my side. Would be great to have other reviews as well.

@wesleybl

Copy link
Copy Markdown
Member Author

@wesleybl How can I reproduce the issue? It seems to be working okay for me on https://demo.plone.org/edit in Firefox.

@davisagli I couldn't reproduce the issue on https://demo.plone.org. Perhaps because it uses a different theme?

But I was able to reproduce it with vanilla Volto installed locally.

@wesleybl

Copy link
Copy Markdown
Member Author

I removed the modification in Edit.jsx. The fix works without it. This makes the solution simpler and preserves the previous behavior.

In edit, clicking on a Slate block would cause the click position to be lost, with the cursor jumping to the beginning of the text.
Now, we save the position and set it on the Slate block after it is selected.

@Wagner3UB Wagner3UB left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good. Thank you.

@Wagner3UB Wagner3UB assigned Wagner3UB and wesleybl and unassigned Wagner3UB Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants