Scroll to selected item when opening Combobox
with multiple: false
#2702
Labels
Milestone
Combobox
with multiple: false
#2702
Description
We would like the ability to have the selected option visible (scrolling to it) when opening a combobox that only allows a single selected value. The specific use case here is a dropdown for selecting the year in our new Datepicker component. There can potentially be a lot of years that are allowed to select, and you usually want to select something close to the current year. Its also best to show years in chronological order. Since we by default allow selecting ±100 years, this results in the year
2124
being shown first when opening the dropdown, and the user has to scroll very far to find the current year.This was reported to us as a bug after releasing the our new Datepicker: Altinn/app-frontend-react#2637
We managed to create a workaround for this, but we had to get very creative as it seems impossible to wrap a
Combobox.Option
component due touseCombobox
checking that the type is ComboboxOption.Workaround: https://github.com/Altinn/app-frontend-react/pull/2625/files#diff-00f3c7200fc2104ce2875b9ab8ba865cd2d558456b7522ea4a897b15ba7803d4R119-R145
Additional Information
No response
The text was updated successfully, but these errors were encountered: