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

List View: Only show ellipsis on first selected item or when focused #40174

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
9 changes: 8 additions & 1 deletion packages/block-editor/src/components/list-view/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ function ListViewBlock( {
const cellRef = useRef( null );
const [ isHovered, setIsHovered ] = useState( false );
const { clientId } = block;
const isFirstSelectedBlock =
isSelected && selectedClientIds[ 0 ] === clientId;
const isLastSelectedBlock =
isSelected &&
selectedClientIds[ selectedClientIds.length - 1 ] === clientId;

const { toggleBlockHighlight } = useDispatch( blockEditorStore );

Expand Down Expand Up @@ -102,7 +107,7 @@ function ListViewBlock( {

const listViewBlockSettingsClassName = classnames(
'block-editor-list-view-block__menu-cell',
{ 'is-visible': isHovered || isSelected }
{ 'is-visible': isHovered || isFirstSelectedBlock }
);

// If ListView has experimental features related to the Persistent List View,
Expand Down Expand Up @@ -177,6 +182,8 @@ function ListViewBlock( {

const classes = classnames( {
'is-selected': isSelected,
'is-first-selected': isFirstSelectedBlock,
'is-last-selected': isLastSelectedBlock,
'is-branch-selected':
withExperimentalPersistentListViewFeatures && isBranchSelected,
'is-dragging': isDragged,
Expand Down
48 changes: 33 additions & 15 deletions packages/block-editor/src/components/list-view/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,42 @@
}

// Border radius for corners of the selected item.
&.is-selected td:first-child {
border-radius: $radius-block-ui 0 0 $radius-block-ui;
&.is-first-selected td:first-child {
border-top-left-radius: $radius-block-ui;
}
&.is-selected td:last-child {
border-radius: 0 $radius-block-ui $radius-block-ui 0;
&.is-first-selected td:last-child {
border-top-right-radius: $radius-block-ui;
}
&.is-last-selected td:first-child {
border-bottom-left-radius: $radius-block-ui;
}
&.is-last-selected td:last-child {
border-bottom-right-radius: $radius-block-ui;
}
&.is-branch-selected:not(.is-selected) {
// Lighten a CSS variable without introducing a new SASS variable
background:
linear-gradient(transparentize($white, 0.1), transparentize($white, 0.1)),
linear-gradient(var(--wp-admin-theme-color), var(--wp-admin-theme-color));
}
&.is-branch-selected.is-selected td:first-child {
border-radius: $radius-block-ui 0 0 0;
&.is-branch-selected.is-first-selected td:first-child {
border-top-left-radius: $radius-block-ui;
}
&.is-branch-selected.is-selected td:last-child {
border-radius: 0 $radius-block-ui 0 0;
&.is-branch-selected.is-first-selected td:last-child {
border-top-right-radius: $radius-block-ui;
}
&[aria-expanded="false"] {
&.is-branch-selected.is-selected td:first-child {
border-radius: $radius-block-ui 0 0 $radius-block-ui;
&.is-branch-selected.is-first-selected td:first-child {
border-top-left-radius: $radius-block-ui;
}
&.is-branch-selected.is-first-selected td:last-child {
border-top-right-radius: $radius-block-ui;
}
&.is-branch-selected.is-last-selected td:first-child {
border-bottom-left-radius: $radius-block-ui;
}
&.is-branch-selected.is-selected td:last-child {
border-radius: 0 $radius-block-ui $radius-block-ui 0;
&.is-branch-selected.is-last-selected td:last-child {
border-bottom-right-radius: $radius-block-ui;
}
}
&.is-branch-selected:not(.is-selected) td {
Expand Down Expand Up @@ -167,17 +179,23 @@
.block-editor-list-view-block__mover-cell {
line-height: 0;
width: $button-size;
opacity: 0;
vertical-align: middle;
@include reduce-motion("transition");

> * {
opacity: 0;
}

// Show on hover, visible, and show above to keep the hit area size.
&:hover,
&.is-visible {
position: relative;
z-index: 1;
opacity: 1;
@include edit-post__fade-in-animation;

> * {
opacity: 1;
@include edit-post__fade-in-animation;
}
}

&,
Expand Down