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

Zoom Out: Don't pass 'rootClientId' to block lock selectors #64887

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion docs/reference-guides/data/data-core-block-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ _Parameters_

_Returns_

- `boolean | undefined`: Whether the given block is allowed to be moved.
- `boolean`: Whether the given block is allowed to be moved.

### canMoveBlocks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ import useSelectedBlockToolProps from './use-selected-block-tool-props';
import ZoomOutToolbar from './zoom-out-toolbar';

export default function ZoomOutPopover( { clientId, __unstableContentRef } ) {
const {
capturingClientId,
isInsertionPointVisible,
lastClientId,
rootClientId,
} = useSelectedBlockToolProps( clientId );
const { capturingClientId, isInsertionPointVisible, lastClientId } =
useSelectedBlockToolProps( clientId );

const popoverProps = useBlockToolbarPopoverProps( {
contentElement: __unstableContentRef?.current,
Expand Down Expand Up @@ -44,7 +40,6 @@ export default function ZoomOutPopover( { clientId, __unstableContentRef } ) {
<ZoomOutToolbar
__unstableContentRef={ __unstableContentRef }
clientId={ clientId }
rootClientId={ rootClientId }
/>
</BlockPopover>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ import BlockMover from '../block-mover';
import Shuffle from '../block-toolbar/shuffle';
import NavigableToolbar from '../navigable-toolbar';

export default function ZoomOutToolbar( {
clientId,
rootClientId,
__unstableContentRef,
} ) {
export default function ZoomOutToolbar( { clientId, __unstableContentRef } ) {
const selected = useSelect(
( select ) => {
const {
Expand Down Expand Up @@ -65,11 +61,11 @@ export default function ZoomOutToolbar( {
isBlockTemplatePart,
isNextBlockTemplatePart,
isPrevBlockTemplatePart,
canRemove: canRemoveBlock( clientId, rootClientId ),
canMove: canMoveBlock( clientId, rootClientId ),
canRemove: canRemoveBlock( clientId ),
canMove: canMoveBlock( clientId ),
Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can drop the canMove condition. Suffling doesn't change the block's position in the canvas.

};
},
[ clientId, rootClientId ]
[ clientId ]
);

const {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,7 @@ export function canRemoveBlocks( state, clientIds ) {
* @param {Object} state Editor state.
* @param {string} clientId The block client Id.
*
* @return {boolean | undefined} Whether the given block is allowed to be moved.
* @return {boolean} Whether the given block is allowed to be moved.
Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated; just fixed selector's return type.

*/
export function canMoveBlock( state, clientId ) {
const attributes = getBlockAttributes( state, clientId );
Expand Down
Loading