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
fix(ui): save nested richtext inside inlineBlock (#12773)
Removing the `setTimeout` not only doesn't break any tests, but it also
fixes the linked issue.
The long comment above the if statement was added in
#5460 and explains why the if
statement is necessary GIVEN the existence of the `setTimeout`, but the
`setTimeout` was introduced [earlier because the button apparently
didn't work](#1414).
It seems to work now without the `setTimeout`, because otherwise the
tests wouldn't even pass. I also tested it manually, and it works fine.
Fixes#12687
// Only update setModified to true if the form is not already set to modified. Otherwise the following could happen:
101
-
// 1. Text field: someone types in it in an unmodified form
102
-
// 2. After setTimeout triggers setModified(true): form is set to modified. Save Button becomes available. Good!
103
-
// 3. Type something in text field
104
-
// 4. Click on save button before setTimeout in useField has finished (so setModified(true) has not been run yet)
105
-
// 5. Form is saved, setModified(false) is set in the Form/index.tsx `submit` function, "saved successfully" toast appears
106
-
// 6. setModified(true) inside the timeout is run, form is set to modified again, even though it was already saved and thus set to unmodified. Bad! This should have happened before the form is saved. Now the form should be unmodified and stay that way
107
-
// until a NEW change happens. Due to this, the "Leave without saving" modal appears even though it should not when leaving the page fast immediately after saving the document.
108
-
// This is only an issue for forms which have already been set to modified true, as that causes the save button to be enabled. If we prevent this setTimeout to be run
109
-
// for already-modified forms first place (which is unnecessary), we can avoid this issue. As for unmodified forms, this race issue will not happen, because you cannot click the save button faster
110
-
// than the timeout in useField is run. That's because the save button won't even be enabled for clicking until the setTimeout in useField has run.
111
-
// This fixes e2e test flakes, as e2e tests were often so fast that they were saving the form before the timeout in useField has run.
112
-
// Specifically, this fixes the 'should not warn about unsaved changes when navigating to lexical editor with blocks node and then leaving the page after making a change and saving' lexical e2e test.
113
-
if(modified===false){
114
-
// Update modified state after field value comes back
115
-
// to avoid cursor jump caused by state value / DOM mismatch
0 commit comments