Skip to content

Fix entity list highlighted instance focus & scroll - #792

Merged
aguingand merged 2 commits into
10.xfrom
fix/entity-list-highlighted-instance
Oct 30, 2026
Merged

aguingand merged 2 commits into
10.xfrom
fix/entity-list-highlighted-instance

Conversation

@aguingand

@aguingand aguingand commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

After submitting a form, the edited instance should be highlighted in the list (focused and scrolled into view). It often wasn't:

  • Full-page list: the row link was focused, but Inertia's Scroll.reset() (window.scrollTo(0, 0) after page swap) ran right after, so the row ended up off screen.
  • Rows beyond the first rendered chunk (50) weren't in the DOM, so nothing was found.
  • Wrong link: the [data-instance-row] a selector could match a link inside an HTML field rendered before the row overlay link.
  • Show page with entity map (configureEntityMap): highlighted_entity_key is the item's entity (e.g. post-block-visuals) while Show.vue compared it to the field's entityListKey (post-block), so the highlight was never applied (and a collapsed list never expanded).

Fix

  • focusHighlightedInstance(): renders enough rows to include the highlighted instance, waits two animation frames (after Inertia's scroll reset), then scrollIntoView({ block: 'center' }) the row and focuses its link with preventScroll.
  • Row overlay link is targeted via a dedicated data-row-link attribute.
  • Rows without a link are not focused / scrolled.
  • Entity list form links (edit, and entity map create) get an entity_list_key query param (the key of the list they're opened from). FormController passes it to the form endpoint and uses it as highlighted_entity_key on redirect / cancel (falling back to the form entity base key). HandleInertiaRequests strips it from the browser URL. So the existing highlightedEntityKey === entityListKey check in Show.vue works with entity maps, including auto-expanding a collapsed list.

Tests

  • Updated form URL expectations in EntityListControllerTest / ApiEntityListControllerTest; added a FormControllerTest case for entity_list_key (endpoint, cancel URL, update & store redirects).
  • Checked manually on the demo with Playwright: posts list (last row, page scrolled + link focused; failed before the fix) and post Show page with the post blocks entity map in a collapsed section (list expands, row focused and in view; not at all before).

🤖 Generated with Claude Code

aguingand and others added 2 commits October 30, 2026 12:53
- Scroll the highlighted row into view after Inertia's scroll reset, and focus its link
- Render enough rows for the highlighted instance to be found
- Match highlighted instance on entity key (new _meta.entityKey), so it works with entity maps in Show pages
- Don't focus / scroll rows without link

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Add an `entity_list_key` query param to entity list form links (edit and entity map create), passed through the form endpoint and used as `highlighted_entity_key` on redirect / cancel
- Strip `entity_list_key` from the browser URL
- Remove `_meta.entityKey` and restore the Show page highlight plumbing: a collapsed Show entity list with an entity map now opens on the highlighted row

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aguingand
aguingand merged commit 7412d11 into 10.x Oct 30, 2026
7 checks passed
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.

1 participant