-
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
Fix duplicate navigation block props #43596
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 |
---|---|---|
@@ -1,8 +1,3 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
|
@@ -42,7 +37,6 @@ const ALLOWED_BLOCKS = [ | |
]; | ||
|
||
export default function UnsavedInnerBlocks( { | ||
blockProps, | ||
blocks, | ||
clientId, | ||
hasSavedUnsavedInnerBlocks, | ||
|
@@ -83,12 +77,17 @@ export default function UnsavedInnerBlocks( { | |
const isDisabled = useContext( Disabled.Context ); | ||
const savingLock = useRef( false ); | ||
|
||
const innerBlocksProps = useInnerBlocksProps( blockProps, { | ||
renderAppender: hasSelection ? undefined : false, | ||
allowedBlocks: ALLOWED_BLOCKS, | ||
__experimentalDefaultBlock: DEFAULT_BLOCK, | ||
__experimentalDirectInsert: shouldDirectInsert, | ||
} ); | ||
const innerBlocksProps = useInnerBlocksProps( | ||
{ | ||
className: 'wp-block-navigation__container', | ||
}, | ||
{ | ||
renderAppender: hasSelection ? undefined : false, | ||
allowedBlocks: ALLOWED_BLOCKS, | ||
__experimentalDefaultBlock: DEFAULT_BLOCK, | ||
__experimentalDirectInsert: shouldDirectInsert, | ||
} | ||
); | ||
|
||
const { isSaving, draftNavigationMenus, hasResolvedDraftNavigationMenus } = | ||
useSelect( | ||
|
@@ -172,18 +171,9 @@ export default function UnsavedInnerBlocks( { | |
const Wrapper = isSaving ? Disabled : 'div'; | ||
|
||
return ( | ||
<Wrapper className="wp-block-navigation__unsaved-changes"> | ||
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. There used to be an overlay to prevent direct manipulation, but I don't think this is needed anymore. It causes the styling of the inner blocks to be incorrect. There must be direct descendent selectors among the block styles, so I think it's best to try to match the DOM structure that the block normally has. This could do with some testing, but I believe the unsaved inner blocks are save upon editing now, and it seemed to work ok for me. It's questionable if the I did spot some issues that are also present in trunk, like the way links added after page list are aligned to the right: |
||
<div | ||
className={ classnames( | ||
'wp-block-navigation__unsaved-changes-overlay', | ||
{ | ||
'is-saving': isSaving, | ||
} | ||
) } | ||
> | ||
<div { ...innerBlocksProps } /> | ||
</div> | ||
<> | ||
<Wrapper { ...innerBlocksProps } /> | ||
{ isSaving && <Spinner /> } | ||
</Wrapper> | ||
</> | ||
); | ||
} |
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.
Matches
innerBlocksProps
elsewhere.