Skip to content

Commit 8510531

Browse files
authored
Don't scroll separator when setting focus (#683)
1 parent 31831c3 commit 8510531

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 4.7.2 (unreleased)
4+
5+
- [683](https://github.com/bvaughn/react-resizable-panels/pull/683): Don't scroll separator when setting focus
6+
37
## 4.7.1
48

59
- [678](https://github.com/bvaughn/react-resizable-panels/pull/678): Change default overflow styles to support shadows

lib/global/event-handlers/onDocumentKeyDown.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ export function onDocumentKeyDown(event: KeyboardEvent) {
120120
: 0;
121121

122122
const nextSeparatorElement = separatorElements[nextIndex] as HTMLElement;
123-
nextSeparatorElement.focus();
123+
nextSeparatorElement.focus({
124+
preventScroll: true
125+
});
124126
break;
125127
}
126128
case "Home": {

lib/global/event-handlers/onDocumentPointerDown.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export function onDocumentPointerDown(event: PointerEvent) {
2323
if (!didChangeFocus) {
2424
didChangeFocus = true;
2525

26-
current.separator.element.focus();
26+
current.separator.element.focus({
27+
preventScroll: true
28+
});
2729
}
2830
}
2931

0 commit comments

Comments
 (0)