-
Notifications
You must be signed in to change notification settings - Fork 109
fix: Remember cursor position when autofocus on load #4540
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
Conversation
Signed-off-by: Julius Härtl <[email protected]>
mejo-
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, works really well. Will have to adjust https://github.com/nextcloud/collectives/blob/main/src/components/Page/TextEditor.vue#L150 afterwards to make this work in Collectives.
Probably something we should backport to stable27 and stable26 because it fixes an annoying usability bug, right?
Together with nextcloud/text#4540, the cursor position will be restored when opening the editor for a page. Signed-off-by: Jonas <[email protected]>
|
nextcloud/collectives#795 is the corresponding PR for Collectives. |
1 failed tests on run #11148 ↗︎Details:
|
|||||||||||||||||||||
| Test | Artifacts | |
|---|---|---|
| Sync > passes the doc content from one session to the next |
Output
Screenshots
|
|
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.
|
/compile |
Yes, would definitely do that. |
Signed-off-by: nextcloud-command <[email protected]>
After thinking more about it, I wonder whether it would be better to store this in |
|
Yes, the cleanup was the main reason why I picked session storage as it seemed more short living. I'd rather get this in now and then iteratively improve. |
|
/backport cd552ef to stable27 |
|
/backport cd552ef to stable26 |
|
Think I merged too fast, https://cloud.cypress.io/projects/hx9gqy/runs/11150/test-results/0a248360-1a30-4eae-89ac-64c7a3a593d4 seems related, I'll look into that tomorrow. |
Together with nextcloud/text#4540, the cursor position will be restored when opening the editor for a page. Signed-off-by: Jonas <[email protected]>
📝 Summary
From being personally annoyed by it, this is a naive attempt to resolve #4140 to focus on the last cursor position. The position is remembered in the session storage per file and will be restored if present, otherwise we focus on the start (instead of the end).
Note that this may lead to cursor offsets if the document was changed in the meantime but so far I couldn't think of a proper way to get the position state relative to a node within the y.js doc and this should already improve the situation quite a bit. Even if the position is not exactly matching it seems more sane to focus close enough rather than to the end.
🏁 Checklist
npm run lint/npm run stylelint/composer run cs:check)