Skip to content

FSHSP-210 fix(overlay): share one body scroll lock across the kit - #142

Merged
LBU4SH merged 1 commit into
mainfrom
claude/eager-turing-33824d
Sep 14, 2026
Merged

LBU4SH merged 1 commit into
mainfrom
claude/eager-turing-33824d

Conversation

@LBU4SH

@LBU4SH LBU4SH commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

lockBodyScroll / unlockBodyScroll were copy-pasted, byte for byte, into the five entry points that mask the viewport: ui-modal, ui-drawer, ui-bottom-sheet, ui-sidebar and ui-image-preview (FSHSP-198).

Each entry point is its own compilation unit, so each copy carried its own scrollLockCount — five counters, each convinced it alone held the body. Two overlays that do not close in the reverse order of their opening then break: the counter of the one leaving drops to 0 and hands the page back while an overlay is still on screen. Unwinding in strict LIFO order happens to be benign — each copy restores the value the next one re-applies — which is why this went unnoticed.

  • Helper moved to @4sh/ui-kit/overlay, next to closeOnNavigation, and exported from its public-api. The move is behaviour-preserving; the five components import it by package name, so ng-packagr records the edge and builds overlay first. overlay still imports no component entry point.
  • Regression test in ui-modal.spec.ts nests a drawer under a modal and closes the modal first. It imports @4sh/ui-kit/layout/ui-drawer, which resolves to dist/, so it crosses the real entry-point boundary rather than a source-level shortcut. Verified to fail before this change.
  • body-scroll-lock.spec.ts pins the ref-counting arithmetic itself.

`lockBodyScroll` / `unlockBodyScroll` were copy-pasted, byte for byte, into
the five entry points that mask the viewport: `ui-modal`, `ui-drawer`,
`ui-bottom-sheet`, `ui-sidebar` and `ui-image-preview` (FSHSP-198).

Each entry point is its own compilation unit, so each copy carried its own
`scrollLockCount` — five counters, each convinced it alone held the body.
Two overlays that do not close in the reverse order of their opening then
break: the counter of the one leaving drops to 0 and hands the page back
while an overlay is still on screen. Unwinding in strict LIFO order happens
to be benign — each copy restores the value the next one re-applies — which
is why this went unnoticed.

- Helper moved to `@4sh/ui-kit/overlay`, next to `closeOnNavigation`, and
  exported from its `public-api`. The move is behaviour-preserving; the five
  components import it by package name, so `ng-packagr` records the edge and
  builds `overlay` first. `overlay` still imports no component entry point.
- Regression test in `ui-modal.spec.ts` nests a drawer under a modal and
  closes the modal first. It imports `@4sh/ui-kit/layout/ui-drawer`, which
  resolves to `dist/`, so it crosses the real entry-point boundary rather
  than a source-level shortcut. Verified to fail before this change.
- `body-scroll-lock.spec.ts` pins the ref-counting arithmetic itself.
@LBU4SH
LBU4SH merged commit 8af1cc5 into main Sep 14, 2026
3 checks passed
@LBU4SH
LBU4SH deleted the claude/eager-turing-33824d branch September 14, 2026 12:42
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