-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds all allowed innerblocks to the inspector animation experiment (#…
…47834) * adds all allowed innerblocks to the inspector animation experiment * don't animate unless we're in a navigation block * make the nav block a config * Update packages/block-editor/src/components/block-inspector/index.js Co-authored-by: Andrei Draganescu <me@andreidraganescu.info> * remove redundant comment * be more clear block animation is temporary --------- Co-authored-by: scruffian <ben@scruffian.com>
- Loading branch information
1 parent
eac1d5f
commit 105625a
Showing
3 changed files
with
78 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/block-editor/src/components/block-inspector/useBlockInspectorAnimationSettings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useSelect } from '@wordpress/data'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as blockEditorStore } from '../../store'; | ||
|
||
export default function useBlockInspectorAnimationSettings( | ||
blockType, | ||
selectedBlockClientId | ||
) { | ||
return useSelect( | ||
( select ) => { | ||
if ( blockType ) { | ||
const globalBlockInspectorAnimationSettings = | ||
select( blockEditorStore ).getSettings() | ||
.blockInspectorAnimation; | ||
|
||
// Get the name of the block that will allow it's children to be animated. | ||
const animationParent = | ||
globalBlockInspectorAnimationSettings?.animationParent; | ||
|
||
// Determine whether the animationParent block is a parent of the selected block. | ||
const { getSelectedBlockClientId, getBlockParentsByBlockName } = | ||
select( blockEditorStore ); | ||
const _selectedBlockClientId = getSelectedBlockClientId(); | ||
const animationParentBlockClientId = getBlockParentsByBlockName( | ||
_selectedBlockClientId, | ||
animationParent, | ||
true | ||
)[ 0 ]; | ||
|
||
// If the selected block is not a child of the animationParent block, | ||
// and not an animationParent block itself, don't animate. | ||
if ( | ||
! animationParentBlockClientId && | ||
blockType.name !== animationParent | ||
) { | ||
return null; | ||
} | ||
|
||
return globalBlockInspectorAnimationSettings?.[ | ||
blockType.name | ||
]; | ||
} | ||
return null; | ||
}, | ||
[ selectedBlockClientId, blockType ] | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105625a
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.
Flaky tests detected in 105625a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4250645007
📝 Reported issues:
specs/editor/various/multi-block-selection.test.js
specs/editor/various/multi-block-selection.test.js