Avoid persisting preference every time the sidebar tab is changed#40923
Merged
Conversation
|
Size Change: +927 B (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
43a1bcd to
feee560
Compare
Mamaduka
reviewed
May 13, 2022
Mamaduka
approved these changes
May 13, 2022
Member
Mamaduka
left a comment
There was a problem hiding this comment.
Thanks, @talldan.
This tests well, and the code looks good to me. I left a small comment regarding the actions.
I think the first drawback is most noticeable in the Site Editor, but it should be okay as long as we agree this is a correct new behavior.
dd70315 to
1299fcd
Compare
1299fcd to
0c23e93
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What?
Attempts to solve the feedback here - #39795 (comment)
Why?
For a long time, we've been saving which type of sidebar is active (document, block, global styles, plugin sidebar) as a preference.
This was ok when the preferences were only persisted in local storage. Since #39795, persisting preferences has involved an HTTP request, and this is potentially expensive for such a regular action as changing which sidebar is visible.
How?
This introduces less granular preferences state
isComplementaryAreaVisible, which is only set when the sidebar is closed or opened. The type/name of the sidebar that's open is now stored only in-memory using a reducer in the interface store.Drawbacks
This does mean if the user had Global Styles or the Navigation sidebar open in the site editor, when they reload the page the 'document' sidebar will instead be open.
There's a situation where a sidebar/complementary area can be open, but we don't know exactly which type of sidebar to display (because the 'area' is no longer persisted). In this case I've introduced the
setDefaultComplementaryAreaaction, which is used when initializing the site editor (and used in the site editor, which doesn't show a sidebar by default).Testing Instructions