Skip to content
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

Zoom Out: Disable zoom out toggle button when Style Book is open #66228

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/editor/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function Header( {
) }

{ canBeZoomedOut && isEditorIframed && isWideViewport && (
<ZoomOutToggle />
<ZoomOutToggle disabled={ forceDisableBlockTools } />
) }

<PreviewDropdown
Expand Down
4 changes: 3 additions & 1 deletion packages/editor/src/components/zoom-out-toggle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { store as preferencesStore } from '@wordpress/preferences';
*/
import { unlock } from '../../lock-unlock';

const ZoomOutToggle = () => {
const ZoomOutToggle = ( { disabled } ) => {
const { isZoomOut, showIconLabels } = useSelect( ( select ) => ( {
isZoomOut: unlock( select( blockEditorStore ) ).isZoomOut(),
showIconLabels: select( preferencesStore ).get(
Expand All @@ -37,6 +37,8 @@ const ZoomOutToggle = () => {

return (
<Button
accessibleWhenDisabled
disabled={ disabled }
Comment on lines +40 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL about this new prop.

Interesting that we don't just set accessibleWhenDisabled to true by default. I assume there's some logical reason why that's not the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I only learned about it thanks to the linter! As far as I can tell it's optional in Ariakit (https://ariakit.org/reference/button#accessiblewhendisabled), so I imagine our Button component has it optional either for consistency or back compat. I agree it feels a bit redundant, though, having to set it in a bunch of places as in Gutenberg I imagine we'd want to be using it all the time.

Good to keep in mind for future consolidation, for sure 👍

onClick={ handleZoomOut }
icon={ zoomOutIcon }
label={ __( 'Zoom Out' ) }
Expand Down
Loading