Skip to content

Commit ca10e4b

Browse files
committed
Prevent autoscroll to the root columns container to prevent jump on page load
https://app.fizzy.do/5986089/cards/3160
1 parent 396c1ff commit ca10e4b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

app/javascript/controllers/navigable_list_controller.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default class extends Controller {
1414
hasNestedNavigation: { type: Boolean, default: false },
1515
preventHandledKeys: { type: Boolean, default: false },
1616
autoSelect: { type: Boolean, default: true },
17+
autoScroll: { type: Boolean, default: true },
1718
onlyActOnFocusedItems: { type: Boolean, default: false }
1819
}
1920

@@ -80,10 +81,10 @@ export default class extends Controller {
8081

8182
await nextFrame()
8283

83-
this.currentItem.scrollIntoView({ block: "nearest", inline: "nearest" })
84+
if (this.autoScrollValue) { this.currentItem.scrollIntoView({ block: "nearest", inline: "nearest" }) }
8485
if (this.hasNestedNavigationValue) { this.#activateNestedNavigableList() }
8586

86-
if (!skipFocus && this.focusOnSelectionValue) { this.currentItem.focus() }
87+
if (!skipFocus && this.focusOnSelectionValue) { this.currentItem.focus({ preventScroll: !this.autoScrollValue }) }
8788
}
8889

8990
isSelected(item) {
@@ -160,7 +161,7 @@ export default class extends Controller {
160161
#relayNavigationToParentNavigableList(event) {
161162
const parentController = this.#parentNavigableListController
162163
if (parentController) {
163-
parentController.element.focus()
164+
parentController.element.focus({ preventScroll: !this.autoScrollValue })
164165
parentController.navigate(event)
165166
}
166167
}

app/views/boards/show/_columns.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
navigable_list_has_nested_navigation_value: true,
1111
navigable_list_prevent_handled_keys_value: true,
1212
navigable_list_auto_select_value: false,
13+
navigable_list_auto_scroll_value: false,
1314
action: "
1415
keydown->navigable-list#navigate
1516
dragstart->drag-and-drop#dragStart

0 commit comments

Comments
 (0)