Fixes the cursor position when clicking on a Slate block - #8402
Conversation
|
I noticed that this is happening even when there are few blocks. Further investigation is needed. This didn't happen before. |
e571f1d to
40affe7
Compare
|
Upon closer inspection, I noticed the issue affects only a few blocks, and specifically within the 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 How can I reproduce the issue? It seems to be working okay for me on https://demo.plone.org/edit in Firefox. |
|
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
left a comment
There was a problem hiding this comment.
Lgtm from my side. Would be great to have other reviews as well.
@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. |
40affe7 to
160112a
Compare
|
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.
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.