Skip to content

refactor!: rewrite master-detail-layout with CSS grid#11361

Merged
web-padawan merged 38 commits intomainfrom
feat/mdl-2.0
Mar 18, 2026
Merged

refactor!: rewrite master-detail-layout with CSS grid#11361
web-padawan merged 38 commits intomainfrom
feat/mdl-2.0

Conversation

@web-padawan
Copy link
Copy Markdown
Member

@web-padawan web-padawan commented Mar 16, 2026

Summary

Fixes #11343
Part of #11345
Part of #11346
Part of #11347

  • Replace flexbox layout with CSS grid using 4-column tracks with named lines
  • Remove properties: masterMinSize, detailMinSize, forceOverlay, stackOverlay
  • Renamed containment property to overlayContainment, added overlaySize
  • Remove [drawer]/[stack] attributes, use [has-detail][overflow] instead
  • Preserve view transitions, events, ARIA, and focus management from old implementation
  • Update Aura theme selectors and transition styles
  • Add ARCHITECTURE.md with design documentation

Test plan

  • yarn test --group master-detail-layout (74 unit tests pass)
  • yarn test:snapshots --group master-detail-layout (5 snapshot tests pass)
  • yarn update:base --group master-detail-layout (regenerate base screenshots)
  • yarn update:lumo --group master-detail-layout (regenerate Lumo screenshots)
  • yarn update:aura --group master-detail-layout (regenerate Aura screenshots)
  • Manual testing with yarn start → dev/master-detail-layout.html

🤖 Generated with Claude Code

BREAKING CHANGE: Replace flexbox layout with CSS grid. Remove properties:
masterMinSize, detailMinSize, forceOverlay, stackOverlay, containment.
Add properties: detailOverlayMode, expand. Remove [drawer]/[stack]
attributes, use [has-detail][overflow] with [detail-overlay-mode] instead.

Co-Authored-By: Sergey Vinogradov <mr.vursen@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
vursen and others added 7 commits March 17, 2026 10:57
…write in rAF

Move DOM/style reads to the synchronous ResizeObserver callback where
layout is already calculated, and defer writes to requestAnimationFrame.
This eliminates the Debouncer, __scheduleResize, and queueMicrotask
batching in favor of the natural read/write separation. Property
observers no longer manually schedule resizes since ResizeObserver
picks up size changes from CSS custom property updates automatically.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Round the sum of computed grid track sizes before comparing with
offsetWidth to avoid false overflow when the host has a fractional
width (offsetWidth returns an integer while track sizes are sub-pixel).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use :scope > selector in querySelectorAll to prevent observing nested
descendants, which caused unnecessary __onResize calls.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The [has-detail] attribute check is unnecessary in overlay selectors
since the overlay state already implies a detail is present.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Call __onResize(true) in _finishTransition() before resolving the
update callback. Without this, the browser takes the "new" snapshot
before has-detail/overflow are set, causing the backdrop to flash
in after the transition instead of being part of it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add fallback values (1fr/0/min-content) for var(--_master-size)
  and var(--_detail-size) so grid template stays valid without
  explicit sizes
- Require [has-master-size] on preserve-master-width rule to
  prevent master width jump when masterSize is not set
- Require [has-detail] on view-transition-name selectors to avoid
  capturing 0-sized detail in the old transition snapshot
- Fix split-mode border to only show when detail is present

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@web-padawan web-padawan force-pushed the feat/mdl-2.0 branch 3 times, most recently from 2e84271 to 0cb787c Compare March 17, 2026 09:41
- __onResize(): remove sync parameter, always run synchronously.
  Sets has-detail before reading overflow so --_detail-column
  reflects correct state. ResizeObserver defers via Debouncer(rAF).
- _finishTransition(): use queueMicrotask instead of sync call.
  Microtask runs before Promise resolution propagates to
  startViewTransition, ensuring correct snapshot.
- CSS: collapse detail column to 0 when has-detail absent.
- Test helper: extra nextRender for rAF-deferred __onResize.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
web-padawan and others added 5 commits March 17, 2026 12:21
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ounding issues

Replace offsetWidth/offsetHeight with getComputedStyle().width/height for
the host size comparison and use Math.floor instead of Math.round, since
offsetWidth rounds fractional sizes to integers which can mask real overflow
(e.g. 599.6px rounds up to 600, matching a 300+300 track sum).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
vursen and others added 7 commits March 17, 2026 15:42
…umn template

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ment

Simplify the overlay API by splitting the combined detailOverlayMode
property into two independent properties: overlaySize (CSS length for
the overlay panel) and overlayContainment ('layout'/'viewport').

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…perty

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…anch

Also restore orientation JSDoc from main to reduce PR diff.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
web-padawan and others added 12 commits March 17, 2026 16:02
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The test duplicated the existing overlay role="dialog" assertion since
overlaySize does not affect ARIA behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove duplicate fixed positioning and backdrop tests from the combined
overlaySize + overlayContainment section. Use forEach over orientations
to reduce boilerplate.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Set default --_master-size (30em) and --_detail-size (15em) in :host
instead of using fallback values, removing the need for has-*-size
attributes in CSS selectors. Update ARCHITECTURE.md and DOM snapshots.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
web-padawan and others added 4 commits March 18, 2026 10:04
Fix unit typo (rem -> em) and use same wording as .js file.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix Math.round -> Math.floor in overflow detection description.
Add missing expand='master' selector in preserve-master-width example.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When expand='detail' and no detail content is present, the detail grid
tracks would still reserve space, shrinking the master area. Apply the
same calc(100% - masterSize) compensation used for expand='both' and
expand='master' to push the empty detail tracks off-screen.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@web-padawan web-padawan merged commit 98bc745 into main Mar 18, 2026
10 checks passed
@web-padawan web-padawan deleted the feat/mdl-2.0 branch March 18, 2026 09:04
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.

MDL: Refactor overflow detection to prevent layout thrashing

2 participants