Skip to content

Commit 8970520

Browse files
committed
fix: skip preventDefault on scrollbar mousedown in version combobox
The onMouseDown handler on the <ul> popup called preventDefault() unconditionally. In Chromium and Safari, mousedown on a scrollbar targets the scrollable element, so preventDefault cancelled native scrollbar drag/jump when versions overflowed max-height. Only call preventDefault when the target is a descendant (a list item), not the <ul> itself. When event.target === event.currentTarget the click hit the scrollbar track or padding, and the <ul> is not focusable so focus stays in the input without intervention.
1 parent 2fc3d34 commit 8970520

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎website/src/pages/playground/PlaygroundVersionCombobox.tsrx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,11 @@ export function PlaygroundVersionCombobox(props: PlaygroundVersionComboboxProps)
270270
aria-label="Octane versions"
271271
hidden={!open}
272272
// Keep focus in the input on any press inside the list, so its blur
273-
// does not close the popup.
274-
onMouseDown={(event: MouseEvent) => event.preventDefault()}
273+
// does not close the popup. Let clicks that hit the scrollbar
274+
// track (target === the ul itself) through so native scroll works.
275+
onMouseDown={(event: MouseEvent) => {
276+
if (event.target !== event.currentTarget) event.preventDefault();
277+
}}
275278
>
276279
@for (const item of options; key item) {
277280
<li

0 commit comments

Comments
 (0)