-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Avoid persisting preference every time the sidebar tab is changed #40923
Conversation
Size Change: +927 B (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
43a1bcd
to
feee560
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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
setDefaultComplementaryArea
action, which is used when initializing the site editor (and used in the site editor, which doesn't show a sidebar by default).Testing Instructions