From 96f789fc828a7d8aba0b526ee98134d790cd6555 Mon Sep 17 00:00:00 2001 From: MariaBanaszkiewicz <80327686+MariaBanaszkiewicz@users.noreply.github.com> Date: Thu, 7 Nov 2024 11:41:28 +0100 Subject: [PATCH] [@mantine/core] Combobox: Fix incorrect logic of selected options when the dropdown is closed without selecting value (#7039) --- .../use-combobox-target-props/use-combobox-target-props.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/@mantine/core/src/components/Combobox/use-combobox-target-props/use-combobox-target-props.ts b/packages/@mantine/core/src/components/Combobox/use-combobox-target-props/use-combobox-target-props.ts index 8b97da7ebbb..d6178a8b5e0 100644 --- a/packages/@mantine/core/src/components/Combobox/use-combobox-target-props/use-combobox-target-props.ts +++ b/packages/@mantine/core/src/components/Combobox/use-combobox-target-props/use-combobox-target-props.ts @@ -40,6 +40,7 @@ export function useComboboxTargetProps({ if (!ctx.store.dropdownOpened) { ctx.store.openDropdown('keyboard'); setSelectedOptionId(ctx.store.selectActiveOption()); + ctx.store.updateSelectedOptionIndex('selected', { scrollIntoView: true }); } else { setSelectedOptionId(ctx.store.selectNextOption()); } @@ -51,6 +52,7 @@ export function useComboboxTargetProps({ if (!ctx.store.dropdownOpened) { ctx.store.openDropdown('keyboard'); setSelectedOptionId(ctx.store.selectActiveOption()); + ctx.store.updateSelectedOptionIndex('selected', { scrollIntoView: true }); } else { setSelectedOptionId(ctx.store.selectPreviousOption()); }