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

How to clear cursor state on editor blur #342

Closed
rcbevans opened this issue Apr 20, 2022 · 3 comments
Closed

How to clear cursor state on editor blur #342

rcbevans opened this issue Apr 20, 2022 · 3 comments

Comments

@rcbevans
Copy link

On my page I am using two slate editors for different parts of the same document.

Currently, once a user clicks into the editor, their cursor position is shared with all other collaborators and renders correctly (thanks for the hint to use cursorStateField to differentiate the cursor position data for each), but the cursor position persistes even once the user blurs the editor.

If a user clicks into each editor, other users see a cursor for the user in each of the editors, rather than the editor where their cursor currently is. Is it possible to clear the cursor position data on blur of the slate editor?

@rcbevans
Copy link
Author

I added

              onBlur={() => {
                editor.sendCursorPosition(null);
              }}

to the Editable component and this does seem to clear the cursor position when the editor loses focus, however on focus again, the cursor position is not synced again until the user moves the cursor to a new position in the editor text.

@BitPhinix
Copy link
Owner

Sorry for taking so long to come back to this, will add a option for it in #363 🙏

@BitPhinix
Copy link
Owner

It's included via the useUnsetCursorPositionOnBlur hook in https://github.com/BitPhinix/slate-yjs/pull/363/files#diff-5f9695b6035d0b13922dc5a300a83513b0dc0d4a93790b85c9b58d0acb257f0d. Will merge and release a new version of slate-react in 1-2 days

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

No branches or pull requests

2 participants