Skip to content

Commit

Permalink
Group: fix padding select (WordPress#65857)
Browse files Browse the repository at this point in the history
Co-authored-by: ellatrix <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
3 people authored Oct 21, 2024
1 parent 75e3366 commit 12c8ca7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// hack a progressive enhancement.
/* stylelint-disable -- Stylelint is disabled to allow the hack to work. */
_::-webkit-full-page-media, _:future, :root .block-editor-block-list__layout::selection,
_::-webkit-full-page-media, _:future, :root .has-multi-selection .block-editor-block-list__layout::selection {
_::-webkit-full-page-media, _:future, :root [data-has-multi-selection="true"] .block-editor-block-list__layout::selection {
background-color: transparent;
}
/* stylelint-enable */
Expand Down
8 changes: 5 additions & 3 deletions packages/block-editor/src/components/writing-flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,21 @@ export function useWritingFlow() {
useRefEffect(
( node ) => {
node.tabIndex = 0;
node.dataset.hasMultiSelection = hasMultiSelection;

if ( ! hasMultiSelection ) {
return;
return () => {
delete node.dataset.hasMultiSelection;
};
}

node.classList.add( 'has-multi-selection' );
node.setAttribute(
'aria-label',
__( 'Multiple selected blocks' )
);

return () => {
node.classList.remove( 'has-multi-selection' );
delete node.dataset.hasMultiSelection;
node.removeAttribute( 'aria-label' );
};
},
Expand Down
12 changes: 12 additions & 0 deletions packages/block-library/src/group/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
}
}

// Reset user select, but the next rule should take precedence for nested
// groups.
:where([data-has-multi-selection]:not([contenteditable="true"]) .wp-block-group > *) {
user-select: initial;
}

// When we are not multi-selecting, prevent children from capturing the
// selection, which happens when the group is flex and children inlined.
:where([data-has-multi-selection]:not([contenteditable="true"]) .wp-block-group) {
user-select: none;
}

// Place block list appender in the same place content will appear.
[data-type="core/group"].is-selected {
.block-list-appender {
Expand Down

0 comments on commit 12c8ca7

Please sign in to comment.