-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Perform dirty detection as diff against saved post #1996
Conversation
As previously discussed, this makes me a bit nervous because we are moving away from a pretty simple and predictable approach based on whether or not the user takes specific actions to something more like what we have in Calypso, and this has problems: Automattic/wp-calypso#9833 and others. Undoubtedly there are a lot of differences between Calypso and Gutenberg, one being that we have no lingering history of using Flux as a data store. Still, if this has the potential to cause difficult-to-diagnose problems later on, then I don't think it's worth it. What do you think? How can we avoid repeating the same bugs that exist in the Calypso editor here? |
The current situation is certainly not much better, in that we prompt the user that there are changes when there may be none at all, only because they performed some action that triggered the dirty flag, or some rogue action dispatch flipped it into the dirty state. Historical issues with dirtiness in Calypso can be attributed partly to its handling of content in two separate formats: "HTML content" and "raw content". To some extent we still have that here, only in that editing content in Text mode needs its value represented as a string. In all other cases, we can work with blocks as raw objects, which should hopefully be less unpredictable. Undo could play a role here. If I come to rely on it for reversing changes, it could be a non-issue. Depending on if I as a user...
I'd say end-to-end tests could help surface these problems, but then again, the prompts in Calypso have in many cases been browser-specific (IE11 and Firefox off the top of my head). |
01f5a4c
to
810988b
Compare
Codecov Report
@@ Coverage Diff @@
## master #1996 +/- ##
==========================================
+ Coverage 24.06% 24.37% +0.31%
==========================================
Files 149 150 +1
Lines 4592 4615 +23
Branches 775 783 +8
==========================================
+ Hits 1105 1125 +20
- Misses 2946 2947 +1
- Partials 541 543 +2
Continue to review full report at Codecov.
|
@aduth I don't have strong opinions about this one other than the vague concerns noted above. If you think this is the best way forward then let's do it. |
810988b
to
abc0b3d
Compare
This is a tricky piece to get correct, and I have some reservations about the proposed implementation (dealing with editor history, juggling text view value). That said, I do think it's in our interest to try to make it work. I've rebased and made a few revisions: Canceling pending autosave on I'm gonna give this another thorough round of testing in the morning and merge if all looks good. At least being early in the week gives us some breathing room to resolve potential issues 😉 |
Can be difficult to adhere when interdependant functions in same file. Not error-prone.
abc0b3d
to
da5cbe7
Compare
…use_polyfill Update project to use react-native-url-polyfill package for the URL class
Closes #916
This pull request seeks to refactor dirty detection not as a property of state, but instead as a selector whose return value is determined by a difference between state and the last saved copy of the post.
Implementation notes:
This one turned out to be more of a sprawling refactor than I would have liked, particularly around:
editor.edits
reducer to omit values matching the reset postTextEditor
to operate without an explicitmarkDirty
action creatorIt may be worth splitting these into smaller pull requests.
Some remaining tasks include:
editor/tests/state.js
Testing instructions:
Verify that the "Save" option is only presented when changes exist to be saved. Notably:
Demonstration of the last item:
Caveats:
Editable values are only reflected in state after blurring the editable fields. Dirtiness detection will only update at these intervals.