Skip to content

Commit

Permalink
Combobox: 🐛 Fix scroll issue when using arrow keys in list (#3299)
Browse files Browse the repository at this point in the history
  • Loading branch information
HalvorHaugan authored Oct 30, 2024
1 parent 1ac9ec2 commit 76937a0
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .changeset/silver-dingos-mate.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"@navikt/ds-css": patch
---

Combobox: only apply filteredOptions scroll offset when max options is rendered
Combobox: :bug: Fix scroll issue when using arrow keys to navigate list
4 changes: 0 additions & 4 deletions @navikt/core/css/darkside/form/combobox.darkside.css
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,6 @@
border: 1px solid var(--ac-combobox-list-item-max-selected-border, var(--a-border-info));
}

.navds-combobox__list--max-selected .navds-combobox__list-item {
scroll-margin-top: 50px;
}

.navds-combobox__list_non-selectables:hover {
cursor: default;
}
Expand Down
4 changes: 0 additions & 4 deletions @navikt/core/css/form/combobox.css
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,6 @@
border: 1px solid var(--ac-combobox-list-item-max-selected-border, var(--a-border-info));
}

.navds-combobox__list--max-selected .navds-combobox__list-item {
scroll-margin-top: 50px;
}

.navds-combobox__list_non-selectables:hover {
cursor: default;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ const FilteredOptions = () => {
<ul
ref={setFilteredOptionsRef}
role="listbox"
className={cl("navds-combobox__list-options", {
"navds-combobox__list--max-selected": maxSelected?.isLimitReached,
})}
className="navds-combobox__list-options"
>
{isValueNew && !maxSelected?.isLimitReached && allowNewValues && (
<AddNewOption />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const useVirtualFocus = (

const setActiveAndScrollToElement = (element?: HTMLElement) => {
setActiveElement(element);
element?.scrollIntoView?.({ block: "nearest" });
element?.scrollIntoView?.({ block: "center" });
};

const moveFocusUp = () => {
Expand Down

0 comments on commit 76937a0

Please sign in to comment.