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

Collapse classic meta boxes under details element #64247

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
15 changes: 13 additions & 2 deletions packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ function useEditorStyles() {
] );
}

function MetaBoxesDetails() {
return (
<details className="edit-post-layout__metaboxes-details">
<summary className="edit-post-layout__metaboxes-details-summary">
{ __( 'Meta Boxes' ) }
</summary>
<MetaBoxes location="normal" />
<MetaBoxes location="advanced" />
</details>
);
}

function Layout( {
postId: initialPostId,
postType: initialPostType,
Expand Down Expand Up @@ -361,8 +373,7 @@ function Layout( {
! isDistractionFree &&
showMetaBoxes && (
<div className="edit-post-layout__metaboxes">
<MetaBoxes location="normal" />
<MetaBoxes location="advanced" />
<MetaBoxesDetails />
</div>
)
}
Expand Down
23 changes: 23 additions & 0 deletions packages/edit-post/src/components/layout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@
clear: both;
}

.edit-post-layout__metaboxes-details {
background: $white;
border-top: $border-width solid $gray-200;
}

.edit-post-layout__metaboxes-details[open] {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}

.edit-post-layout__metaboxes-details summary {
cursor: pointer;
color: $gray-900;
height: 24px;
line-height: 24px;
font-size: 13px;
list-style-position: outside;
margin-left: 24px;
}

// Adjust the position of the notices
.components-editor-notices__snackbar {
position: fixed;
Expand Down
43 changes: 18 additions & 25 deletions packages/edit-post/src/components/layout/use-should-iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,29 @@ import { store as editorStore } from '@wordpress/editor';
import { useSelect } from '@wordpress/data';
import { store as blocksStore } from '@wordpress/blocks';

/**
* Internal dependencies
*/
import { store as editPostStore } from '../../store';

const isGutenbergPlugin = globalThis.IS_GUTENBERG_PLUGIN ? true : false;

export function useShouldIframe() {
const {
isBlockBasedTheme,
hasV3BlocksOnly,
isEditingTemplate,
hasMetaBoxes,
} = useSelect( ( select ) => {
const { getEditorSettings, getCurrentPostType } = select( editorStore );
const { getBlockTypes } = select( blocksStore );
const editorSettings = getEditorSettings();
return {
isBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme,
hasV3BlocksOnly: getBlockTypes().every( ( type ) => {
return type.apiVersion >= 3;
} ),
isEditingTemplate: getCurrentPostType() === 'wp_template',
hasMetaBoxes: select( editPostStore ).hasMetaBoxes(),
};
}, [] );
const { isBlockBasedTheme, hasV3BlocksOnly, isEditingTemplate } = useSelect(
( select ) => {
const { getEditorSettings, getCurrentPostType } =
select( editorStore );
const { getBlockTypes } = select( blocksStore );
const editorSettings = getEditorSettings();
return {
isBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme,
hasV3BlocksOnly: getBlockTypes().every( ( type ) => {
return type.apiVersion >= 3;
} ),
isEditingTemplate: getCurrentPostType() === 'wp_template',
};
},
[]
);

return (
( ( hasV3BlocksOnly || ( isGutenbergPlugin && isBlockBasedTheme ) ) &&
! hasMetaBoxes ) ||
hasV3BlocksOnly ||
( isGutenbergPlugin && isBlockBasedTheme ) ||
Copy link
Member

Choose a reason for hiding this comment

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

Side note: I think we should remove the special treatment for the Gutenberg plugin. The different behavior from the WP core sometimes results in discovering no-framed editor bugs after the code has shipped.

Sorry, I can't remember examples now, but having the same condition in both builds makes sense, IMO.

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking the same as I was reviewing this. The conditional here seems odd at this point

Copy link
Member Author

Choose a reason for hiding this comment

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

We are discussing this, I want to formally remove it in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

100%. My comment was just a side note.

isEditingTemplate
);
}
Loading