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

Safari's "Select All" menu item fails when content is larger than the viewport #1052

Closed
hubgit opened this issue Jan 4, 2023 · 3 comments
Closed

Comments

@hubgit
Copy link
Contributor

hubgit commented Jan 4, 2023

Describe the issue

When "Select All" is selected from a browser's "Edit" menu, it should behave the same as pressing the keyboard shortcut (Cmd/Ctrl+A): a selection should be created covering the whole doc.

This works as expected in Chrome and Firefox, and works as expected in all browsers when using the keyboard shortcut.

However, when "Select All" is selected from Safari's "Edit" menu, and the editor content is larger than the viewport, the cursor will be placed at the start or end of the document and no selection will be created.

Browser and platform

Safari 16.2, macOS 13.1

Reproduction link

https://codemirror.net/try/?c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge2phdmFzY3JpcHR9IGZyb20gIkBjb2RlbWlycm9yL2xhbmctamF2YXNjcmlwdCIKCm5ldyBFZGl0b3JWaWV3KHsKICBkb2M6ICJjb25zb2xlLmxvZygnaGVsbG8nKVxuIi5yZXBlYXQoMTAwMCksCiAgZXh0ZW5zaW9uczogW2Jhc2ljU2V0dXAsIGphdmFzY3JpcHQoKV0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5Cn0pCg==

@marijnh
Copy link
Member

marijnh commented Jan 5, 2023

Indeed, I can reproduce this. It appears to be caused by the presence of an uneditable element at the start or end of the document, which somehow breaks off Safari's native select-all. Unfortunately, it doesn't fire a beforeinput event when the user picks select-all. I'm not sure yet how we could detect this happening.

@hubgit
Copy link
Contributor Author

hubgit commented Jan 5, 2023

Good point about the uneditable element - it does seem to work as expected if the div with contenteditable=false is deleted.

It sounds like webkit bugs 108987 and 124765, perhaps (old but recently active).

There's also a related Chrome bug, but I haven't been able to reproduce that in CodeMirror, even when there are spacer contenteditable=false divs at both the start and end of the document.

@marijnh
Copy link
Member

marijnh commented Aug 30, 2023

Going to close this, it being a browser bug that we can't really work around.

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