Skip to content

Commit 31d97ab

Browse files
chapterjasonclaude
andcommitted
Allow native touch scroll of topbar
Touches starting inside the topbar no longer get preventDefault'd by the focus-swallowing handler, so the browser's native horizontal overflow scroll works on mobile. Desktop focus-stealing prevention stays intact via pointerdown/mousedown. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 0889a4f commit 31d97ab

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/keyboard/virtual-keyboard.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,15 @@ export class VirtualKeyboard extends HTMLElement {
124124
</div>
125125
`;
126126
const swallowFocus = (e: Event): void => e.preventDefault();
127+
const swallowFocusUnlessTopbar = (e: Event): void => {
128+
const target = e.target as HTMLElement | null;
129+
if (target?.closest(".topbar")) return;
130+
e.preventDefault();
131+
};
127132
const host = this.#root.querySelector(".vk");
128133
host?.addEventListener("pointerdown", swallowFocus);
129134
host?.addEventListener("mousedown", swallowFocus);
130-
host?.addEventListener("touchstart", swallowFocus, { passive: false });
135+
host?.addEventListener("touchstart", swallowFocusUnlessTopbar, { passive: false });
131136
this.#renderTopbar();
132137
this.#attachDragScroll(this.#root.querySelector(".topbar") as HTMLElement);
133138
this.#render();

0 commit comments

Comments
 (0)