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

Block Supports: Add non-default ToolsPanel items if props change, eg. on styles paste #47673

Closed
wants to merge 3 commits into from
Closed
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
9 changes: 0 additions & 9 deletions packages/block-editor/src/components/block-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ export default function BlockActions( {
setBlockMovingClientId,
setNavigationMode,
selectBlock,
clearSelectedBlock,
multiSelect,
} = useDispatch( blockEditorStore );

const notifyCopy = useNotifyCopy();
Expand Down Expand Up @@ -134,13 +132,6 @@ export default function BlockActions( {
},
async onPasteStyles() {
await pasteStyles( blocks );

// Need to reselect the block(s) in order for optional tool panel control changes to register.
clearSelectedBlock();
multiSelect(
blocks[ 0 ].clientId,
blocks[ blocks.length - 1 ].clientId
);
},
} );
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ export function useToolsPanelItem(
flagItemCustomization,
] );

useEffect( () => {
if ( ! isShownByDefault && isValueSet && ! wasValueSet ) {
console.log(
'Do something here to make non-default items with values updated show'
);
}
}, [ isShownByDefault, isValueSet, wasValueSet ] );

// Note: `label` is used as a key when building menu item state in
// `ToolsPanel`.
const menuGroup = isShownByDefault ? 'default' : 'optional';
Expand Down