Skip to content

Commit

Permalink
fix(Select): activate first clickable item (#1228)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturAbdullin authored Dec 27, 2023
1 parent 75778c7 commit 13b921e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/Select/__stories__/SelectShowcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ export const SelectShowcase = (props: SelectProps) => {
code={[EXAMPLE_DISABLED_OPTIONS]}
selectProps={props}
>
<Select.Option value="val1" content="Value1" />
<Select.Option value="val2" content="Value2" disabled />
<Select.Option value="val1" content="Value1" disabled />
<Select.Option value="val2" content="Value2" />
<Select.Option value="val3" content="Value3" disabled />
<Select.Option value="val4" content="Value4" />
</ExampleItem>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Select/utils.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -210,8 +211,7 @@ export const getActiveItem = (listRef: React.RefObject<List<FlattenOption>>) =>

export const activateFirstClickableItem = (listRef: React.RefObject<List<FlattenOption>>) => {
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) => {
Expand Down

0 comments on commit 13b921e

Please sign in to comment.