Skip to content

Fix item detail for datagrid nested in another component - #1300

Open
radimvaculik wants to merge 1 commit into
masterfrom
fix/item-detail-nested-component
Open

Fix item detail for datagrid nested in another component#1300
radimvaculik wants to merge 1 commit into
masterfrom
fix/item-detail-nested-component

Conversation

@radimvaculik

Copy link
Copy Markdown
Member

Fixes #1299

Problem

Datagrid renders data-datagrid-name="{$control->getFullName()}" (src/templates/datagrid.latte:17), so datagrid.name in JS is the component full name (eg. myComponent-grid). The detail row class uses the full name too (item-detail-{$control->getFullname()}-id-...).

But ItemDetailPlugin compared datagrid.name against data-toggle-detail-grid, which only holds the plain name (grid). For a datagrid placed directly in a presenter both values are equal and everything works; as soon as the grid lives inside another component the comparison never matches and the item detail never toggles.

Fix

src/Column/ItemDetail.php already renders data-toggle-detail-grid-fullname (added back in c1b5f57 "ItemDetail fix for multiple datagrids at same page") — the TypeScript plugin just never started using it during the jQuery → vanilla TS rewrite. The plugin now prefers the full name attribute and falls back to the plain one for hand-rendered buttons.

No PHP change needed.

Notes

Other plugins (checkboxes.ts, inline.ts) compare against data-check / payload._datagrid_name, both of which are already filled with the full name, so they are not affected.

ItemDetailPlugin porovnával data-toggle-detail-grid (plain name) proti
datagrid.name, který je full name komponenty, takže se u vnořeného gridu
detail nikdy nerozbalil. Plugin nyní preferuje již renderovaný atribut
data-toggle-detail-grid-fullname.
@codecov

codecov Bot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.12%. Comparing base (ab5506d) to head (dd78ae8).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1300   +/-   ##
=======================================
  Coverage   49.12%   49.12%           
=======================================
  Files          63       63           
  Lines        2974     2974           
=======================================
  Hits         1461     1461           
  Misses       1513     1513           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Item - detail bug when grid has parent component

2 participants