Merged PR 2067: fix(ui-layout): Ipad Dropdown Scrolling Fix

fix(ui-layout): Ipad Dropdown Scrolling Fix
This commit is contained in:
Nino Righi
2025-12-03 14:16:21 +00:00
committed by Lorenz Hilpert
parent aa57d27924
commit d5324675ef
2 changed files with 10 additions and 4 deletions

3
.gitignore vendored
View File

@@ -80,3 +80,6 @@ CLAUDE.md
*.pyc *.pyc
.vite .vite
reports/ reports/
# Local iPad dev setup (proxy)
/local-dev/

View File

@@ -84,8 +84,11 @@ export class CloseOnScrollDirective implements OnDestroy {
} }
this.#isActive = true; this.#isActive = true;
// Delay listener registration to next frame to skip any stale scroll events // Delay listener registration to skip scroll events caused by:
this.#pendingActivation = requestAnimationFrame(() => { // 1. Stale scroll events from before activation
// 2. iOS Safari's automatic "scroll into view" when focusing elements
// Using setTimeout with 100ms to ensure iOS scroll-into-view completes
this.#pendingActivation = window.setTimeout(() => {
this.#scrollListener = (event: Event) => { this.#scrollListener = (event: Event) => {
const excludeElement = this.closeOnScrollExclude(); const excludeElement = this.closeOnScrollExclude();
if (excludeElement?.contains(event.target as HTMLElement)) { if (excludeElement?.contains(event.target as HTMLElement)) {
@@ -101,12 +104,12 @@ export class CloseOnScrollDirective implements OnDestroy {
{ capture: true, passive: true }, { capture: true, passive: true },
); );
this.#logger.debug('Activated scroll listener'); this.#logger.debug('Activated scroll listener');
}); }, 100);
} }
#deactivate(): void { #deactivate(): void {
if (this.#pendingActivation) { if (this.#pendingActivation) {
cancelAnimationFrame(this.#pendingActivation); clearTimeout(this.#pendingActivation);
this.#pendingActivation = undefined; this.#pendingActivation = undefined;
} }