-
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
Update fixed block toolbar #52123
Update fixed block toolbar #52123
Changes from 7 commits
e2b8257
c2bb12b
5dddd7b
cf34ee6
11cfa84
672fdb8
31ede3c
5989fa7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,9 @@ export default function HeaderEditMode() { | |
}; | ||
}, [] ); | ||
|
||
const { get: getPreference } = useSelect( preferencesStore ); | ||
const hasFixedToolbar = getPreference( editSiteStore.name, 'fixedToolbar' ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we make this a hook so we can share the code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To me a two liner is not worth a hok. I would be if the two liner would be some arcane expression or something but this is really basic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same comment as above - https://github.com/WordPress/gutenberg/pull/52123/files#r1252980401. |
||
|
||
const { | ||
__experimentalSetPreviewDeviceType: setPreviewDeviceType, | ||
setIsInserterOpened, | ||
|
@@ -213,14 +216,18 @@ export default function HeaderEditMode() { | |
) } | ||
{ isLargeViewport && ( | ||
<> | ||
<ToolbarItem | ||
as={ ToolSelector } | ||
showTooltip={ ! showIconLabels } | ||
variant={ | ||
showIconLabels ? 'tertiary' : undefined | ||
} | ||
disabled={ ! isVisualMode } | ||
/> | ||
{ ! hasFixedToolbar && ( | ||
<ToolbarItem | ||
as={ ToolSelector } | ||
showTooltip={ ! showIconLabels } | ||
variant={ | ||
showIconLabels | ||
? 'tertiary' | ||
: undefined | ||
} | ||
disabled={ ! isVisualMode } | ||
/> | ||
) } | ||
<ToolbarItem | ||
as={ UndoButton } | ||
showTooltip={ ! showIconLabels } | ||
|
@@ -257,7 +264,8 @@ export default function HeaderEditMode() { | |
/> | ||
) } | ||
{ isZoomedOutViewExperimentEnabled && | ||
! isDistractionFree && ( | ||
! isDistractionFree && | ||
! hasFixedToolbar && ( | ||
<ToolbarItem | ||
as={ Button } | ||
className="edit-site-header-edit-mode__zoom-out-view-toggle" | ||
|
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.
This isn't a good way to use selectors when value is used during the render. When the
fixedToolbar
preference value changes, this won't rerender the component.Let's make it part of the
useSelect
below.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 made a PR for this: #52332
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's another one in
packages/edit-site/src/components/header-edit-mode/index.js
, let fix both in one go :)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.
done