fix(dashboard): always restore scroll to 0 in useMobileScrollLock cleanup
When App-level activation triggers the lock from an input gaining focus,
iOS may have already scrolled the document by the time the lock effect
runs. Capturing that already-shifted scrollY and restoring it on release
left the dashboard pushed up after the keyboard dismissed (the inline-
edit case). Always snap to 0 instead — the dashboard has body{overflow:
hidden} so user-initiated scroll is always 0 anyway, and any non-zero
value at lock time is iOS-forced and should be reset.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -73,7 +73,8 @@ describe("useMobileScrollLock", () => {
|
||||
expect(document.body.style.top).toBe("5px");
|
||||
expect(document.body.style.overflow).toBe("");
|
||||
expect(document.documentElement.style.overflow).toBe("");
|
||||
expect(scrollSpy).toHaveBeenCalledWith(0, 240);
|
||||
// Always snap to 0 on release — see hook source for rationale.
|
||||
expect(scrollSpy).toHaveBeenCalledWith(0, 0);
|
||||
});
|
||||
|
||||
it("does not lock when disabled", () => {
|
||||
@@ -97,6 +98,6 @@ describe("useMobileScrollLock", () => {
|
||||
|
||||
outer.unmount();
|
||||
expect(document.body.style.position).toBe("");
|
||||
expect(scrollSpy).toHaveBeenCalledWith(0, 80);
|
||||
expect(scrollSpy).toHaveBeenCalledWith(0, 0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user