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

Details: fix multiselect in Chrome #55888

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
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
24 changes: 15 additions & 9 deletions packages/block-library/src/details/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ const TEMPLATE = [
function DetailsEdit( { attributes, setAttributes, clientId } ) {
const { showContent, summary } = attributes;
const blockProps = useBlockProps();
const innerBlocksProps = useInnerBlocksProps( blockProps, {
template: TEMPLATE,
__experimentalCaptureToolbars: true,
} );
const innerBlocksProps = useInnerBlocksProps(
{},
{
template: TEMPLATE,
__experimentalCaptureToolbars: true,
}
);

// Check if either the block or the inner blocks are selected.
const hasSelection = useSelect(
Expand Down Expand Up @@ -58,10 +61,7 @@ function DetailsEdit( { attributes, setAttributes, clientId } ) {
/>
</PanelBody>
</InspectorControls>
<details
{ ...innerBlocksProps }
open={ hasSelection || showContent }
>
<details { ...blockProps } open={ hasSelection || showContent }>
<summary onClick={ ( event ) => event.preventDefault() }>
<RichText
aria-label={ __( 'Write summary' ) }
Expand All @@ -75,7 +75,13 @@ function DetailsEdit( { attributes, setAttributes, clientId } ) {
multiline={ false }
/>
</summary>
{ innerBlocksProps.children }
{
// In Chrome, the details content needs a wrapper div for
// multiselection to work. Chrome internally uses HTML slots
// so this might be an issues when making everything
// `contenteditable`.
}
<div { ...innerBlocksProps } />
</details>
</>
);
Expand Down