You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[lexical] temporarily set editor to not writable when calling getCachedTypeToNodeMap - #7022
This doesn’t seem like the right thing to do, and would cause extra events to fire, what are the preconditions for this problem?
im not sure what other side effects this would introduce, trying it out in a draft PR to experiment, so happy to close if this PR will cause nasty side effects.
this is a followup to the breaking change in #6894. one trigger is a case of editor.registerNodeTransform being called from a useEffect in workplace. that cause workplace post composer to break. i fixed it on the intergration layer, but not sure where else could break as a result of getCachedTypeToNodeMap being called with a writable editor state
This should only be a problem if getEditorState returns a writable state, it’s never supposed to, because that is the state that was most recently reconciled. There is a workaround in there to handle an initial empty EditorState which is not frozen, but maybe there is also a case where your team is creating a non-empty EditorState that is not frozen but still returned from getEditorState somehow? I’m not currently at a computer to look into this but if you can come up with a repro I’m sure we can fix this cleanly
In this scenario what I would do, if I couldn't diagnose and fix the root cause of editor.getEditorState() returning a non-empty writable EditorState under some condition, is expose computeTypeToNodeMap and call that instead when this issue would trigger. You really don't want to populate this cache with a writable EditorState because there's no way to invalidate it if the EditorState changes (because it's not supposed to).
I think the root cause is probably setRootElement(null) which probably just shouldn't be doing this
// If content editable is unmounted we'll reset editor state back to original// (or pending) editor state since there will be no reconciliationthis._editorState=pendingEditorState;this._pendingEditorState=null;this._window=null;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
4 participants
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.
Description
Describe the changes in this pull request
Closes #
Test plan
Before
Insert relevant screenshots/recordings/automated-tests
After
Insert relevant screenshots/recordings/automated-tests