-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Nav offcanvas editor: add simple back button to inspector controls #45852
Changes from all commits
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 |
---|---|---|
|
@@ -136,13 +136,15 @@ const BlockInspector = ( { showNoBlockSelectedMessage = true } ) => { | |
selectedBlockClientId, | ||
blockType, | ||
topLevelLockedBlock, | ||
parentBlockClientId, | ||
} = useSelect( ( select ) => { | ||
const { | ||
getSelectedBlockClientId, | ||
getSelectedBlockCount, | ||
getBlockName, | ||
__unstableGetContentLockingParent, | ||
getTemplateLock, | ||
getBlockParents, | ||
} = select( blockEditorStore ); | ||
|
||
const _selectedBlockClientId = getSelectedBlockClientId(); | ||
|
@@ -161,6 +163,10 @@ const BlockInspector = ( { showNoBlockSelectedMessage = true } ) => { | |
( getTemplateLock( _selectedBlockClientId ) === 'contentOnly' | ||
? _selectedBlockClientId | ||
: undefined ), | ||
parentBlockClientId: getBlockParents( | ||
_selectedBlockClientId, | ||
true | ||
)[ 0 ], | ||
}; | ||
}, [] ); | ||
|
||
|
@@ -230,11 +236,16 @@ const BlockInspector = ( { showNoBlockSelectedMessage = true } ) => { | |
<BlockInspectorSingleBlock | ||
clientId={ selectedBlockClientId } | ||
blockName={ blockType.name } | ||
parentBlockClientId={ parentBlockClientId } | ||
/> | ||
); | ||
}; | ||
|
||
const BlockInspectorSingleBlock = ( { clientId, blockName } ) => { | ||
const BlockInspectorSingleBlock = ( { | ||
clientId, | ||
blockName, | ||
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. Not introduced in this PR but same question for the block name |
||
parentBlockClientId, | ||
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. Can't we retrieve that clientId in this component instead of passing it down? |
||
} ) => { | ||
const showTabs = window?.__experimentalEnableBlockInspectorTabs; | ||
|
||
const hasBlockStyles = useSelect( | ||
|
@@ -247,9 +258,17 @@ const BlockInspectorSingleBlock = ( { clientId, blockName } ) => { | |
); | ||
const blockInformation = useBlockDisplayInformation( clientId ); | ||
|
||
const { selectBlock } = useDispatch( blockEditorStore ); | ||
|
||
return ( | ||
<div className="block-editor-block-inspector"> | ||
<BlockCard { ...blockInformation } /> | ||
<BlockCard | ||
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. It may simplify things if this component just received a "clientId" and handles everything using useSelect/useDispatch internally. There doesn't seem to be a valid reason for all the prop passing down (unless I'm missing something). For the record, I know this is not entirely introduced in this PR :) 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. I raised #45909 to track this. |
||
{ ...blockInformation } | ||
parentBlockClientId={ parentBlockClientId } | ||
handleBackButton={ () => { | ||
selectBlock( parentBlockClientId ); | ||
} } | ||
/> | ||
<BlockVariationTransforms blockClientId={ clientId } /> | ||
{ showTabs && ( | ||
<InspectorControlsTabs | ||
|
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 should also work only for the navigation block
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.
Should it? Why not do it for all child blocks?
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'd like to query how folks think we can do that without tightly coupling the block editor to a specific block.
Also I think it's probably great for all blocks 😄