From bf6761f635c560a3042d4ad15e457807379b9827 Mon Sep 17 00:00:00 2001 From: EldarMuhamethanov <61377022+EldarMuhamethanov@users.noreply.github.com> Date: Wed, 17 Jul 2024 15:34:13 +0300 Subject: [PATCH] fix(ChipsSelect): add open select when focus to form field (#7167) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Убрал логику фокуса на первый чип по нажатию на контейнер --- .../src/components/ChipsInputBase/ChipsInputBase.test.tsx | 4 ++-- .../vkui/src/components/ChipsInputBase/ChipsInputBase.tsx | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/vkui/src/components/ChipsInputBase/ChipsInputBase.test.tsx b/packages/vkui/src/components/ChipsInputBase/ChipsInputBase.test.tsx index 1492ba36a6..bceec73627 100644 --- a/packages/vkui/src/components/ChipsInputBase/ChipsInputBase.test.tsx +++ b/packages/vkui/src/components/ChipsInputBase/ChipsInputBase.test.tsx @@ -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( { ); 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 () => { diff --git a/packages/vkui/src/components/ChipsInputBase/ChipsInputBase.tsx b/packages/vkui/src/components/ChipsInputBase/ChipsInputBase.tsx index be891a7c1b..4e9dff956e 100644 --- a/packages/vkui/src/components/ChipsInputBase/ChipsInputBase.tsx +++ b/packages/vkui/src/components/ChipsInputBase/ChipsInputBase.tsx @@ -181,9 +181,7 @@ export const ChipsInputBase = ({ return; } - if (valueLength > 0 && listboxRef.current) { - moveFocusToChipOption(0, 'first', listboxRef.current); - } else if (inputRef.current) { + if (inputRef.current) { inputRef.current.focus(); } };