Skip to content

Commit 75cf0a6

Browse files
committed
fix scrolling issue when all keyed frameworks are unselected and one becomes selected
1 parent 2ad21d6 commit 75cf0a6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

webdriver-ts-results/src/selection/DropDown.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,18 @@ const DropDown = ({label, children, width}: Props) => {
1212
event.stopPropagation();
1313
setOpen(!open)
1414
}, [open])
15-
return (<div className={(open ? 'open dropdown-container' : 'dropdown-container')}>
15+
const click = (event: React.SyntheticEvent<HTMLElement>) => {
16+
// There's a pretty strange corner case: Click on which frameworks and deselect all keyed
17+
// frameworks. Then select one keyed framework. This will cause scrolling such that the
18+
// which frameworks drop down will be scrolled out of the visible area.
19+
// We prevent this by re-setting the scroll position.
20+
const x = window.scrollX;
21+
const y = window.scrollY;
22+
window.requestAnimationFrame(() => {
23+
window.scrollTo(x, y);
24+
});
25+
}
26+
return (<div onClick={click} className={(open ? 'open dropdown-container' : 'dropdown-container')}>
1627
<button type="button" onClick={toggle} className={(open ? 'open dropdown' : 'dropdown')}>
1728
{label} <span className="caret"></span>
1829
</button>

0 commit comments

Comments
 (0)