Skip to content

Commit

Permalink
fix(ChipsSelect): add open select when focus to form field (#7167)
Browse files Browse the repository at this point in the history
Убрал логику фокуса на первый чип по нажатию на контейнер
  • Loading branch information
EldarMuhamethanov authored and actions-user committed Jul 17, 2024
1 parent 70f0c0e commit bf6761f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe(ChipsInputBase, () => {
expect(result.getByTestId('chips-input')).toHaveFocus();
});

it('focuses to first chip after clicking to container', async () => {
it('focuses to input after clicking to container', async () => {
const result = render(
<ChipsInputBaseTest
value={[RED_OPTION]}
Expand All @@ -160,7 +160,7 @@ describe(ChipsInputBase, () => {
);
const containerEl = result.getByRole('listbox').closest('div')!;
await userEvent.click(containerEl);
expect(result.getByRole('option', { name: withRegExp(RED_OPTION.label) })).toHaveFocus();
expect(result.getByTestId('chips-input')).toHaveFocus();
});

it('focuses on input field on clicking on them', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ export const ChipsInputBase = <O extends ChipOption>({
return;
}

if (valueLength > 0 && listboxRef.current) {
moveFocusToChipOption(0, 'first', listboxRef.current);
} else if (inputRef.current) {
if (inputRef.current) {
inputRef.current.focus();
}
};
Expand Down

0 comments on commit bf6761f

Please sign in to comment.