Skip to content

Commit

Permalink
Fix missing hook deps in distraction free mode (#47611)
Browse files Browse the repository at this point in the history
* Calculate value inline and remove select dependency
  • Loading branch information
getdave authored Feb 1, 2023
1 parent f52ddf3 commit 18e6dc3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions packages/edit-post/src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Header( { setEntitiesSavedStatesCallback } ) {
isPublishSidebarOpened,
isSaving,
showIconLabels,
isDistractionFree,
isDistractionFreeMode,
} = useSelect(
( select ) => ( {
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
Expand All @@ -40,13 +40,14 @@ function Header( { setEntitiesSavedStatesCallback } ) {
isSaving: select( editPostStore ).isSavingMetaBoxes(),
showIconLabels:
select( editPostStore ).isFeatureActive( 'showIconLabels' ),
isDistractionFree:
select( editPostStore ).isFeatureActive( 'distractionFree' ) &&
isLargeViewport,
isDistractionFreeMode:
select( editPostStore ).isFeatureActive( 'distractionFree' ),
} ),
[]
);

const isDistractionFree = isDistractionFreeMode && isLargeViewport;

const classes = classnames( 'edit-post-header' );

const slideY = {
Expand Down
9 changes: 5 additions & 4 deletions packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function Layout( { styles } ) {
isInserterOpened,
isListViewOpened,
showIconLabels,
isDistractionFree,
isDistractionFreeMode,
showBlockBreadcrumbs,
isTemplateMode,
documentLabel,
Expand Down Expand Up @@ -116,9 +116,8 @@ function Layout( { styles } ) {
).getAllShortcutKeyCombinations( 'core/edit-post/next-region' ),
showIconLabels:
select( editPostStore ).isFeatureActive( 'showIconLabels' ),
isDistractionFree:
select( editPostStore ).isFeatureActive( 'distractionFree' ) &&
isLargeViewport,
isDistractionFreeMode:
select( editPostStore ).isFeatureActive( 'distractionFree' ),
showBlockBreadcrumbs: select( editPostStore ).isFeatureActive(
'showBlockBreadcrumbs'
),
Expand All @@ -127,6 +126,8 @@ function Layout( { styles } ) {
};
}, [] );

const isDistractionFree = isDistractionFreeMode && isLargeViewport;

const className = classnames( 'edit-post-layout', 'is-mode-' + mode, {
'is-sidebar-opened': sidebarIsOpened,
'has-fixed-toolbar': hasFixedToolbar,
Expand Down

0 comments on commit 18e6dc3

Please sign in to comment.