Skip to content

Commit

Permalink
Notices: Fix snackbar placement (#60912)
Browse files Browse the repository at this point in the history
* Fix snackbar placement for distraction free, and when blocks breadcrumbs is enabled.

* Add `has-block-breadcrumbs` class only when the preference is set and not in distraction-free mode.

* Update conditionals in favor of readability.

Co-authored-by: juanfra <[email protected]>
Co-authored-by: draganescu <[email protected]>
Co-authored-by: richtabor <[email protected]>
  • Loading branch information
4 people committed Apr 30, 2024
1 parent 8c90f60 commit 667ba29
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ function Layout( { initialPost } ) {
showMetaBoxes,
documentLabel,
hasHistory,
hasBlockBreadcrumbs,
} = useSelect( ( select ) => {
const { get } = select( preferencesStore );
const { getEditorSettings, getPostTypeLabel } = select( editorStore );
Expand Down Expand Up @@ -193,6 +194,7 @@ function Layout( { initialPost } ) {
hasBlockSelected:
!! select( blockEditorStore ).getBlockSelectionStart(),
hasHistory: !! getEditorSettings().onNavigateToPreviousEntityRecord,
hasBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),
};
}, [] );

Expand Down Expand Up @@ -243,6 +245,8 @@ function Layout( { initialPost } ) {
'has-metaboxes': hasActiveMetaboxes,
'is-distraction-free': isDistractionFree && isWideViewport,
'is-entity-save-view-open': !! entitiesSavedStatesCallback,
'has-block-breadcrumbs':
hasBlockBreadcrumbs && ! isDistractionFree && isWideViewport,
} );

const secondarySidebarLabel = isListViewOpened
Expand Down
11 changes: 9 additions & 2 deletions packages/edit-post/src/components/layout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@
.edit-post-layout .components-editor-notices__snackbar {
position: fixed;
right: 0;
bottom: 40px;
bottom: 16px;
padding-left: 16px;
padding-right: 16px;
}

.is-distraction-free {
.components-editor-notices__snackbar {
bottom: 20px;
bottom: 16px;
}
}

// Adjust the position of the notices when breadcrumbs are present
.has-block-breadcrumbs {
.components-editor-notices__snackbar {
bottom: 40px;
}
}

Expand Down
7 changes: 6 additions & 1 deletion packages/edit-site/src/components/editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,16 @@
justify-content: center;
}

// Adjust the position of the notices when breadcrumbs are present
.edit-site .has-block-breadcrumbs.is-full-canvas .components-editor-notices__snackbar {
bottom: 40px;
}

// Adjust the position of the notices
.edit-site .components-editor-notices__snackbar {
position: absolute;
right: 0;
bottom: 40px;
bottom: 16px;
padding-left: 16px;
padding-right: 16px;
}
Expand Down
9 changes: 9 additions & 0 deletions packages/edit-site/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export default function Layout() {
canvasMode,
previousShortcut,
nextShortcut,
hasBlockBreadcrumbs,
} = useSelect( ( select ) => {
const { getAllShortcutKeyCombinations } = select(
keyboardShortcutsStore
Expand All @@ -99,6 +100,10 @@ export default function Layout() {
'core',
'distractionFree'
),
hasBlockBreadcrumbs: select( preferencesStore ).get(
'core',
'showBlockBreadcrumbs'
),
isZoomOutMode:
select( blockEditorStore ).__unstableGetEditorMode() ===
'zoom-out',
Expand Down Expand Up @@ -182,6 +187,10 @@ export default function Layout() {
'has-fixed-toolbar': hasFixedToolbar,
'is-block-toolbar-visible': hasBlockSelected,
'is-zoom-out': isZoomOutMode,
'has-block-breadcrumbs':
hasBlockBreadcrumbs &&
! isDistractionFree &&
canvasMode === 'edit',
}
) }
>
Expand Down

0 comments on commit 667ba29

Please sign in to comment.