Skip to content

fix!: decouple grid row details and selection from activeItem#9612

Merged
vursen merged 13 commits into
mainfrom
fix-details-opened-logic
Jul 1, 2026
Merged

fix!: decouple grid row details and selection from activeItem#9612
vursen merged 13 commits into
mainfrom
fix-details-opened-logic

Conversation

@vursen

@vursen vursen commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Row details and single-selection both relied on activeItem property observers. Routing both through activeItem caused several bugs, which the updated WTR tests now cover:

  • With deselect disallowed, clicking a row with open details failed to close them. The selection observer reverted activeItem, which prevented the details observer from running.
  • Selecting an item from server data opened its details, because the programmatic activeItem change triggered the details observer as if the row had been clicked.

The PR replaces the two activeItem observers with cell-activate and row-activate listeners that read detailsOpened and selected from the event. These events only fire on user interaction, so programmatic changes don't trigger them. There's also no longer any need to mirror selection onto activeItem when selection changes come from the server. As a result, details and selection are now fully independent of activeItem and only react to real clicks.

Warning

This should be a relatively safe change, since rows were always rendered as selected via the selected attribute/part rather than active, and the same applies to details-opened. That said, the activeItem property is no longer populated, which could affect apps that did something based on it in their custom logic.

@vursen vursen changed the title fix: correct grid row details visibility edge cases on click fix: decouple grid row details and selection from activeItem Jun 25, 2026
@vursen vursen changed the title fix: decouple grid row details and selection from activeItem fix!: decouple grid row details and selection from activeItem Jun 25, 2026
@vursen vursen force-pushed the fix-details-opened-logic branch from c8e4742 to d3d38f5 Compare June 25, 2026 10:25
@vaadin vaadin deleted a comment from github-actions Bot Jun 25, 2026

if (selectionMode === 'SINGLE') {
if (item && item.selected && grid.__deselectDisallowed) {
return;

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.

The early return here prevents the details open / closing logic from running. Thus when __deselectDisallowed is active that means clicking on a selected row still prevents details from closing.

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.

Good catch. Fixed.

});

it('should not set details hidden on selected item click when deselect is disallowed', () => {
it('should set details hidden on selected item click when deselect is disallowed', () => {

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.

The clicked item doesn't appear to be selected, at least I can't find any test setup for it.

The test above also doesn't match its description.

@vursen vursen Jun 30, 2026

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.

Fixed these tests to actually select items.

vursen and others added 13 commits June 30, 2026 12:43
Drive row details and single-selection from the grid's cell-activate
and row-activate events instead of two activeItem property observers.
Reading detailsOpened and selected straight from the activated item
decouples details from selection and fixes three cases:

- Details now close when clicking a row whose details are open even
  if deselect is disallowed; before, reverting activeItem stopped the
  details observer from running.
- Selecting an item from server data no longer opens its details;
  before, the programmatic activeItem change triggered the observer.
- Clicking a row with details opened from data now closes them in a
  single click.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ven in tests — from clicking the first cell to dispatching the `row-activate` event (the keyboard activation path), plus new tests for Space-key row selection.

test: drive grid single-selection via row-activate event

- decouple testbench select/deselect from cell clicks so it no
  longer triggers item-click listeners as a side effect
- add tests for selecting and deselecting a row with the Space key
`destroyData` removed the item from the visible-details set, so
details closed after the item left and re-entered the DOM (parent
row collapse/expand, or scrolling out of and back into view).
Return early from onItemActivate when the clicked row has no loaded
item, so a click on a still-loading row no longer triggers selection
or details toggling.

Deselect the clicked item instead of all selected items, so the
decision uses the item's current data rather than stale state.
The row model can keep a stale item while its data reloads, so the
`!item` guard let clicks through during loading. Check the data
provider cache instead, and read selection state from selectedKeys
rather than the stale model item.
@vursen vursen force-pushed the fix-details-opened-logic branch from 90c64d9 to eba5d40 Compare June 30, 2026 08:54
@sonarqubecloud

Copy link
Copy Markdown

@vursen vursen requested a review from sissbruecker June 30, 2026 13:16
@vursen vursen added this pull request to the merge queue Jul 1, 2026
Merged via the queue into main with commit 6f38ac0 Jul 1, 2026
21 checks passed
@vursen vursen deleted the fix-details-opened-logic branch July 1, 2026 08:02
sissbruecker added a commit to sissbruecker/flow-components that referenced this pull request Jul 3, 2026
sissbruecker added a commit to sissbruecker/flow-components that referenced this pull request Jul 3, 2026
sissbruecker added a commit to sissbruecker/flow-components that referenced this pull request Jul 7, 2026
sissbruecker added a commit to sissbruecker/flow-components that referenced this pull request Jul 7, 2026
sissbruecker added a commit to sissbruecker/flow-components that referenced this pull request Jul 7, 2026
sissbruecker added a commit to sissbruecker/flow-components that referenced this pull request Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants