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

Distraction Free Mode: Don't show the metaboxes #48947

Merged
merged 4 commits into from
Mar 9, 2023
Merged
Changes from 1 commit
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
18 changes: 9 additions & 9 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,
isDistractionFreeMode,
isDistractionFree,
showBlockBreadcrumbs,
isTemplateMode,
documentLabel,
Expand Down Expand Up @@ -116,7 +116,7 @@ function Layout( { styles } ) {
).getAllShortcutKeyCombinations( 'core/edit-post/next-region' ),
showIconLabels:
select( editPostStore ).isFeatureActive( 'showIconLabels' ),
isDistractionFreeMode:
isDistractionFree:
select( editPostStore ).isFeatureActive( 'distractionFree' ),
showBlockBreadcrumbs: select( editPostStore ).isFeatureActive(
'showBlockBreadcrumbs'
Expand All @@ -126,8 +126,6 @@ function Layout( { styles } ) {
};
}, [] );

const isDistractionFree = isDistractionFreeMode && isLargeViewport;

const openSidebarPanel = () =>
openGeneralSidebar(
hasBlockSelected ? 'edit-post/block' : 'edit-post/document'
Expand Down Expand Up @@ -164,7 +162,7 @@ function Layout( { styles } ) {
'has-fixed-toolbar': hasFixedToolbar,
'has-metaboxes': hasActiveMetaboxes,
'show-icon-labels': showIconLabels,
'is-distraction-free': isDistractionFree,
'is-distraction-free': isDistractionFree && isLargeViewport,
'is-entity-save-view-open': !! entitiesSavedStatesCallback,
} );

Expand Down Expand Up @@ -206,7 +204,7 @@ function Layout( { styles } ) {
<EditorKeyboardShortcutsRegister />
<SettingsSidebar />
<InterfaceSkeleton
isDistractionFree={ isDistractionFree }
isDistractionFree={ isDistractionFree && isLargeViewport }
className={ className }
labels={ {
...interfaceLabels,
Expand Down Expand Up @@ -245,14 +243,16 @@ function Layout( { styles } ) {
notices={ <EditorSnackbars /> }
content={
<>
{ ! isDistractionFree && <EditorNotices /> }
{ ( ! isDistractionFree || ! isLargeViewport ) && (
<EditorNotices />
) }
Copy link
Member

Choose a reason for hiding this comment

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

Does this fix another issue? Because it doesn't match isDistractionFreeMode && isLargeViewport.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the original condition is rewritten as is, it will be ! ( isDistractionFree && isLargeViewport ).
Isn't this the same as ( ! isDistractionFree || ! isLargeViewport )? 🤔 Personally, I think this writing style is easier to read.

Copy link
Member

Choose a reason for hiding this comment

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

I think we only want to hide the notices in "distraction-free" mode. We can remove the ! isLargeViewport part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your're right, I have confirmed that removing that section will produce the same expected results as before.

In addition, I have made the following changes in 77ab658 to address the following issues:

I noticed that the distraction-free mode could not be released unless the notice message bar was turned off, because it overlapped the header area. This may be a bug, but I think it should be addressed in a separate issue.

This should completely hide the notice message in distraction-free mode.

This comment was marked as duplicate.

Copy link
Member

@Mamaduka Mamaduka Mar 9, 2023

Choose a reason for hiding this comment

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

I would prefer if we address those issues separately. Let's just fix the metabox issue in this PR.

{ ( mode === 'text' || ! isRichEditingEnabled ) && (
<TextEditor />
) }
{ isRichEditingEnabled && mode === 'visual' && (
<VisualEditor styles={ styles } />
) }
{ ! isTemplateMode && (
{ ! isDistractionFree && ! isTemplateMode && (
<div className="edit-post-layout__metaboxes">
<MetaBoxes location="normal" />
<MetaBoxes location="advanced" />
Expand All @@ -265,8 +265,8 @@ function Layout( { styles } ) {
}
footer={
! isDistractionFree &&
showBlockBreadcrumbs &&
! isMobileViewport &&
showBlockBreadcrumbs &&
isRichEditingEnabled &&
mode === 'visual' && (
Comment on lines 265 to 269
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing appears to have changed here, but the isDistractionFree variable no longer contains the viewport width condition.

This fixes another problem. In trunk, there is a "gap" in the viewport width generated by this conditional statement, so the breadcrumb list is displayed when the viewport width is between 782px and 960px, even in distraction-free mode, as shown below.

87835d47b037b1cc67e9e3bfdcc5f478.mp4

<div className="edit-post-layout__footer">
Expand Down