FSHSP-210 fix(overlay): share one body scroll lock across the kit - #142
Merged
Merged
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
lockBodyScroll/unlockBodyScrollwere copy-pasted, byte for byte, into the five entry points that mask the viewport:ui-modal,ui-drawer,ui-bottom-sheet,ui-sidebarandui-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.@4sh/ui-kit/overlay, next tocloseOnNavigation, and exported from itspublic-api. The move is behaviour-preserving; the five components import it by package name, song-packagrrecords the edge and buildsoverlayfirst.overlaystill imports no component entry point.ui-modal.spec.tsnests a drawer under a modal and closes the modal first. It imports@4sh/ui-kit/layout/ui-drawer, which resolves todist/, so it crosses the real entry-point boundary rather than a source-level shortcut. Verified to fail before this change.body-scroll-lock.spec.tspins the ref-counting arithmetic itself.