Ignore iOS mutations when unfocused #2170
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We're running into a weird bug where NodeViews get stuck an infinite loop of mounting and unmounting when they contain an iframe. This causes a React maximum update depth exceeded crash, and also causes the content of some of those nodeviews to be wiped out.
To reproduce, try visiting https://9hgxv.csb.app/ on an iPhone. The same code works fine on a desktop.
We believe the issue is related to the default
ignoreMutation
method, which returns false when contenteditable nodes are added on iOS. I don't understand all the context of this function, but we found that patching this function to add a check forthis.editor.isFocused
(to narrow the if statement to only apply when triggered by the user's keyboard) fixed it in our fork.We previously raised this issue in #1971 but thought it was fixed. It turns out it was only partially fixed. Instead of happening with all nodeviews in iOS, it now only seems to happen in the narrower case when the iframe is present. But the fix described in #1971 still works.
Related issues: #1214, ProseMirror/prosemirror#1162 (comment)