Prevent autoscroll to the root columns container to prevent jump on page load

https://app.fizzy.do/5986089/cards/3160
This commit is contained in:
Jorge Manrubia
2025-11-25 21:01:18 +01:00
parent 396c1ffdcf
commit ca10e4ba4e
2 changed files with 5 additions and 3 deletions
@@ -14,6 +14,7 @@ export default class extends Controller {
hasNestedNavigation: { type: Boolean, default: false },
preventHandledKeys: { type: Boolean, default: false },
autoSelect: { type: Boolean, default: true },
autoScroll: { type: Boolean, default: true },
onlyActOnFocusedItems: { type: Boolean, default: false }
}
@@ -80,10 +81,10 @@ export default class extends Controller {
await nextFrame()
this.currentItem.scrollIntoView({ block: "nearest", inline: "nearest" })
if (this.autoScrollValue) { this.currentItem.scrollIntoView({ block: "nearest", inline: "nearest" }) }
if (this.hasNestedNavigationValue) { this.#activateNestedNavigableList() }
if (!skipFocus && this.focusOnSelectionValue) { this.currentItem.focus() }
if (!skipFocus && this.focusOnSelectionValue) { this.currentItem.focus({ preventScroll: !this.autoScrollValue }) }
}
isSelected(item) {
@@ -160,7 +161,7 @@ export default class extends Controller {
#relayNavigationToParentNavigableList(event) {
const parentController = this.#parentNavigableListController
if (parentController) {
parentController.element.focus()
parentController.element.focus({ preventScroll: !this.autoScrollValue })
parentController.navigate(event)
}
}