-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
[view] Occasional "undefined is not an object (evaluating 'e.contentEditable')" error in Safari #1152
Comments
Interesting. So either Safari is reporting an invalid position in the selection, or ProseMirror's selection object is out of date, or the DOM is being sneakily mutated by the browser as we are in the process of inspecting it (it's happened before). If all else fails, I guess we could add a check for this and bail out here without too much adverse effects, but if this is a situation where we end up with the wrong selection range, that would indicate a bigger problem. Do you know if the editor is inside a shadow root when this occurs? This could be related to a kludge to work around Safari's lack of working selection object in shadow roots. |
It seems the Safari issue that is the reason for the hack that might be causing this has been closed a few months ago. I am not well-versed enough in Apple release cycles to know what Safari version that fix will end up in, though. |
The editor is not inside a shadow root. I'll try to spend some time in Safari and see if I can reproduce the error. |
I haven’t yet got a reliable reproduction for this, but I’ve managed to catch the exception in Safari in a couple of situations:
Seeing |
|
Apologies for the incomplete nature of the bug report still - I'm able to trigger it by dispatching a remote change that deletes all the content in the doc while the selection’s inside a snippet highlight, which isn't exactly minimal. I can try to answer questions as much as possible:
This is where the exception is thrown, after dispatching the change: This is what This is what I found an issue which may or may not be relevant; it at least contains a jsfiddle showing that Safari updates |
FIX: Validate selection offsets reported by the browser, to work around Safari giving us invalid values in some cases. Issue codemirror/dev#1152
Then I suppose we are looking at a Safari bug (a Attached patch adds validation for these offsets. Could you see if you can apply that and then try to reproduce this again? |
Thank you - it looks like I can no longer reproduce the issue in Safari, using v6.11.2 which includes this patch. |
Describe the issue
I haven't been able to reproduce this error, so I'm not sure what triggers it, but we're seeing a reasonably-frequent logging of an error in
@codemirror/view
:The error is triggered here:
https://github.com/codemirror/view/blame/3f1b991f3db20d152045ae9e6872466fc8d8fdac/src/dom.ts#L304
That code was added here, around the time the error started being logged:
codemirror/view@d7312a2
From the logs, this seems to only be triggered in Safari (versions 16 and 15, at least) on macOS.
Would it be possible to add a line that handles the situation where
prev
is undefined, to avoid this error?Browser and platform
Safari, macOS
Reproduction link
No response
The text was updated successfully, but these errors were encountered: