-
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
Selecting Parent Blocks: Try clickthrough #15537
Changes from all commits
47d6de7
2667575
b66cb2d
74920ee
e5a0b12
fafcb1f
0f5ffac
5c28d4b
de050d4
b4b3e76
b0649e1
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
__experimentalAsyncModeProvider as AsyncModeProvider, | ||
useSelect, | ||
} from '@wordpress/data'; | ||
|
||
const BlockAsyncModeProvider = ( { children, clientId, isBlockInSelection } ) => { | ||
const isParentOfSelectedBlock = useSelect( ( select ) => { | ||
return select( 'core/block-editor' ).hasSelectedInnerBlock( clientId, true ); | ||
} ); | ||
|
||
const isSyncModeForced = isBlockInSelection || isParentOfSelectedBlock; | ||
|
||
return ( | ||
<AsyncModeProvider value={ ! isSyncModeForced }> | ||
{ children } | ||
</AsyncModeProvider> | ||
); | ||
}; | ||
|
||
export default BlockAsyncModeProvider; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ import classnames from 'classnames'; | |
/** | ||
* WordPress dependencies | ||
*/ | ||
import { withViewportMatch } from '@wordpress/viewport'; | ||
import { Component } from '@wordpress/element'; | ||
import { withSelect, withDispatch } from '@wordpress/data'; | ||
import { synchronizeBlocksWithTemplate, withBlockContentContext } from '@wordpress/blocks'; | ||
|
@@ -106,14 +105,13 @@ class InnerBlocks extends Component { | |
render() { | ||
const { | ||
clientId, | ||
isSmallScreen, | ||
isSelectedBlockInRoot, | ||
hasOverlay, | ||
renderAppender, | ||
} = this.props; | ||
const { templateInProcess } = this.state; | ||
|
||
const classes = classnames( 'editor-inner-blocks block-editor-inner-blocks', { | ||
'has-overlay': isSmallScreen && ! isSelectedBlockInRoot, | ||
'has-overlay': hasOverlay, | ||
} ); | ||
|
||
return ( | ||
|
@@ -131,7 +129,6 @@ class InnerBlocks extends Component { | |
|
||
InnerBlocks = compose( [ | ||
withBlockEditContext( ( context ) => pick( context, [ 'clientId' ] ) ), | ||
withViewportMatch( { isSmallScreen: '< medium' } ), | ||
withSelect( ( select, ownProps ) => { | ||
const { | ||
isBlockSelected, | ||
|
@@ -142,12 +139,13 @@ InnerBlocks = compose( [ | |
getTemplateLock, | ||
} = select( 'core/block-editor' ); | ||
const { clientId } = ownProps; | ||
const block = getBlock( clientId ); | ||
const rootClientId = getBlockRootClientId( clientId ); | ||
|
||
return { | ||
isSelectedBlockInRoot: isBlockSelected( clientId ) || hasSelectedInnerBlock( clientId ), | ||
block: getBlock( clientId ), | ||
block, | ||
blockListSettings: getBlockListSettings( clientId ), | ||
hasOverlay: block.name !== 'core/template' && ! isBlockSelected( clientId ) && ! hasSelectedInnerBlock( clientId, true ), | ||
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. @youknowriad - any thoughts on this one? It's a really nasty hack to avoid having the overlay in the context of nesting inside Reusable block... 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 think it's fine, ideally, this That PR is blocked by the fact that it's hard to use nested Slot/Fills. One tradeoff we can make to unblock it could be to decide that we don't show the inspector settings for the reusable blocks content and redirect the user to the edit page of the reusable blocks for a full editing session. |
||
parentLock: getTemplateLock( rootClientId ), | ||
}; | ||
} ), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
.block-editor-inner-blocks.has-overlay::after { | ||
content: ""; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
z-index: z-index(".block-editor-inner-blocks__small-screen-overlay:after"); | ||
.block-editor-inner-blocks.has-overlay { | ||
&::after { | ||
content: ""; | ||
position: absolute; | ||
top: -$block-padding; | ||
right: -$block-padding; | ||
bottom: -$block-padding; | ||
left: -$block-padding; | ||
z-index: z-index(".block-editor-inner-blocks.has-overlay::after"); | ||
} | ||
} |
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.
Nit: Conceptually speaking and if there's no impact on performance it would be better to avoid the
isBlockInSelection
as a prop and compute it here :).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.
b0649e1 - I had it before but I assumed it could impact performance. I can try with the previous commit.
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 don't thin that benchmark agrees with this idea:
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.
:)