From 13b921e8384108bf1ca71941e0a5908191cb325e Mon Sep 17 00:00:00 2001 From: Artur Abdullin <30603428+ArturAbdullin@users.noreply.github.com> Date: Wed, 27 Dec 2023 17:22:55 +0300 Subject: [PATCH] fix(Select): activate first clickable item (#1228) --- src/components/Select/__stories__/SelectShowcase.tsx | 4 ++-- src/components/Select/utils.tsx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/Select/__stories__/SelectShowcase.tsx b/src/components/Select/__stories__/SelectShowcase.tsx index ffdcccf65a..6dee20adf7 100644 --- a/src/components/Select/__stories__/SelectShowcase.tsx +++ b/src/components/Select/__stories__/SelectShowcase.tsx @@ -190,8 +190,8 @@ export const SelectShowcase = (props: SelectProps) => { code={[EXAMPLE_DISABLED_OPTIONS]} selectProps={props} > - - + + diff --git a/src/components/Select/utils.tsx b/src/components/Select/utils.tsx index 8e613ea1ea..87eca7e330 100644 --- a/src/components/Select/utils.tsx +++ b/src/components/Select/utils.tsx @@ -1,7 +1,8 @@ import React from 'react'; import {KeyCode} from '../../constants'; -import type {List, ListItemData} from '../List'; +import {List} from '../List'; +import type {ListItemData} from '../List'; import {GROUP_ITEM_MARGIN_TOP, MOBILE_ITEM_HEIGHT, SIZE_TO_ITEM_HEIGHT} from './constants'; import type {Option, OptionGroup} from './tech-components'; @@ -210,8 +211,7 @@ export const getActiveItem = (listRef: React.RefObject>) => export const activateFirstClickableItem = (listRef: React.RefObject>) => { const items = getListItems(listRef); - const isGroupTitleFirstItem = items[0] && 'label' in items[0]; - listRef?.current?.activateItem(isGroupTitleFirstItem ? 1 : 0, false); + listRef?.current?.activateItem(List.findNextIndex(items, 0, 1), false); }; const isOptionMatchedByFilter = (option: SelectOption, filter: string) => {