-
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
Global Styles: Invoke zoomed-out view when selecting a style variation #44987
Global Styles: Invoke zoomed-out view when selecting a style variation #44987
Conversation
Size Change: +60 B (0%) Total Size: 1.27 MB
ℹ️ View Unchanged
|
} | ||
}, [ mode ] ); | ||
|
||
// Intentionality left withou any dependency. |
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.
There are a few typos in this comment.
@@ -120,6 +129,31 @@ function ScreenStyleVariations() { | |||
]; | |||
}, [ variations ] ); | |||
|
|||
const { __unstableSetEditorMode } = useDispatch( blockEditorStore ); | |||
const shouldRevertInitialMode = useRef( null ); | |||
useEffect( () => { |
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.
We're tracking mode changes to decide whether to revert to the initial mode or not. If the user has done any mode changes since the style variations were opened, we won't revert to the initial.
So, in a situation like this:
- user starts in edit mode
- goes to style variations, so the editor is switched automatically to zoom-out mode
- user intentionally switches off zoom-out mode (goes back to edit)
- user intentionally switches on zoom-out mode
- user closes global styles sidebar
What's the expected mode at this point?
With this PR, the mode stays in zoom-out. I think it makes sense because trying to be too smart may be too intrusive. Though, I see how switching off zoom-out mode can be something people do if they want more focus for a specific change, and then going back to the zoom-out. In that flow, staying in zoom-out after closing style variations may be weird.
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.
I opted for this approach because it was the most simple code and seemed to fit most use cases. If you prefer, I can try an approach where if the end mode is still zoom-out we always revert to the initial mode.
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.
There are some typos in the comments.
I've also left a comment on how we decide whether to change to initial mode for future reviewers https://github.com/WordPress/gutenberg/pull/44987/files#r997236444
277ed25
to
05f37df
Compare
Fixes: #44419
This PR opens the zoom-out when the user selects a style variation.
Testing