Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions packages/dataviews/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

### Enhancements

- DataViews table layout: remove row click-to-select behavior and hover styles. Selection is now only possible via checkboxes, or by ctrl/cmd clicking. [#73873](https://github.com/WordPress/gutenberg/pull/73873)
- Field API: move validation to the field type. [#73642](https://github.com/WordPress/gutenberg/pull/73642)
- DataForm: add support for `min`/`max` and `minLength`/`maxLength` validation for relevant controls. [#73465](https://github.com/WordPress/gutenberg/pull/73465)
- Field API: display formats for `number` and `integer` types. [#73644](https://github.com/WordPress/gutenberg/pull/73644)
Expand Down
42 changes: 12 additions & 30 deletions packages/dataviews/src/dataviews-layouts/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,12 @@ function TableRow< Item >( {
const { paginationInfo } = useContext( DataViewsContext );
const hasPossibleBulkAction = useHasAPossibleBulkAction( actions, item );
const isSelected = hasPossibleBulkAction && selection.includes( id );
const [ isHovered, setIsHovered ] = useState( false );
const {
showTitle = true,
showMedia = true,
showDescription = true,
infiniteScrollEnabled,
} = view;
const handleMouseEnter = () => {
setIsHovered( true );
};
const handleMouseLeave = () => {
setIsHovered( false );
};

// Will be set to true if `onTouchStart` fires. This happens before
// `onClick` and can be used to exclude touchscreen devices from certain
// behaviours.
Expand All @@ -150,11 +142,8 @@ function TableRow< Item >( {
<tr
className={ clsx( 'dataviews-view-table__row', {
'is-selected': hasPossibleBulkAction && isSelected,
'is-hovered': isHovered,
'has-bulk-actions': hasPossibleBulkAction,
} ) }
onMouseEnter={ handleMouseEnter }
onMouseLeave={ handleMouseLeave }
onTouchStart={ () => {
isTouchDeviceRef.current = true;
} }
Expand All @@ -168,29 +157,22 @@ function TableRow< Item >( {
return;
}

// Only handle Ctrl/Cmd+Click for multi-selection
const isModifierKeyPressed = isAppleOS()
? event.metaKey
: event.ctrlKey;

if (
isModifierKeyPressed &&
! isTouchDeviceRef.current &&
document.getSelection()?.type !== 'Range'
) {
if ( isAppleOS() ? event.metaKey : event.ctrlKey ) {
// Handle non-consecutive selection.
onChangeSelection(
selection.includes( id )
? selection.filter(
( itemId ) => id !== itemId
)
: [ ...selection, id ]
);
} else {
// Handle single selection
onChangeSelection(
selection.includes( id )
? selection.filter(
( itemId ) => id !== itemId
)
: [ id ]
);
}
// Handle non-consecutive selection with Ctrl/Cmd+Click
onChangeSelection(
selection.includes( id )
? selection.filter( ( itemId ) => id !== itemId )
: [ ...selection, id ]
);
}
} }
>
Expand Down
24 changes: 1 addition & 23 deletions packages/dataviews/src/dataviews-layouts/table/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@
border-bottom: 0;
}

&.is-hovered,

@ntsekouras ntsekouras Dec 11, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we remove these hovered background styles we can end up with this:
Screenshot 2025-12-11 at 4 08 57 PM

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There seems to be a similar issue on trunk with unhovered rows:

Screenshot 2025-12-12 at 12 11 21

But yes I see it's also broken on hover on this PR. I guess it's related to the more general background changes we made, I'll work on a fix.

@jameskoster jameskoster Dec 12, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I fixed the hover state:

Image

But I couldn't find a great solution for the issue on trunk. I think that one probably needs a dedicated PR. I'll open an issue.

Edit: I checked how this works in 6.9 and noticed the column just has a background color:

Image

This was my 'not great' solution 😅 So I guess it's fine to patch it this way for now, and explore a better fix separately.

&.is-hovered .dataviews-view-table__actions-column--sticky {
background-color: #f8f8f8;
}

.dataviews-item-actions .components-button:not(.dataviews-all-actions-button) {
opacity: 0;
}
Expand All @@ -98,35 +93,18 @@
border-top: 1px solid rgba(var(--wp-admin-theme-color--rgb), 0.12);
}

&:hover {
background-color: color-mix(in srgb, rgb(var(--wp-admin-theme-color--rgb)) 8%, $white);
}

.dataviews-view-table__actions-column--sticky {
background-color: color-mix(in srgb, rgb(var(--wp-admin-theme-color--rgb)) 4%, $white);
}

&:hover .dataviews-view-table__actions-column--sticky {
background-color: color-mix(in srgb, rgb(var(--wp-admin-theme-color--rgb)) 8%, $white);
}
}
}

// Hover styles only apply when bulk actions are available
// Show interactive elements on focus
&.has-bulk-actions {
tr {
// Only apply hover background to non-selected rows
&:not(.is-selected) {
&.is-hovered,
&.is-hovered .dataviews-view-table__actions-column--sticky {
background-color: #f8f8f8;
}
}

&:focus-within,
&.is-hovered,
Comment thread
jameskoster marked this conversation as resolved.
Outdated
&:hover {
.components-checkbox-control__input,
Comment thread
jameskoster marked this conversation as resolved.
.dataviews-item-actions .components-button:not(.dataviews-all-actions-button) {
opacity: 1;
}
Expand Down