From 3a43d08f034ea5c0c0cc447555e6e3d4c7905d83 Mon Sep 17 00:00:00 2001 From: hsskey Date: Thu, 9 May 2024 22:30:11 +0900 Subject: [PATCH] fix(core): Ensure TagsInput dropdown reopens on input click after clear --- .../core/src/components/PillsInput/PillsInput.tsx | 10 ++++++++++ .../core/src/components/TagsInput/TagsInput.tsx | 3 +++ 2 files changed, 13 insertions(+) diff --git a/packages/@mantine/core/src/components/PillsInput/PillsInput.tsx b/packages/@mantine/core/src/components/PillsInput/PillsInput.tsx index 4bf24134a1..38289fe424 100644 --- a/packages/@mantine/core/src/components/PillsInput/PillsInput.tsx +++ b/packages/@mantine/core/src/components/PillsInput/PillsInput.tsx @@ -4,6 +4,7 @@ import { __BaseInputProps, __InputStylesNames } from '../Input'; import { InputBase } from '../InputBase'; import { PillsInputProvider } from './PillsInput.context'; import { PillsInputField } from './PillsInputField/PillsInputField'; +import { ComboboxParsedItem } from '../Combobox'; export interface PillsInputProps extends BoxProps, @@ -13,6 +14,9 @@ export interface PillsInputProps __stylesApiProps?: Record; __staticSelector?: string; multiline?: boolean; + openDropdown: () => void; + dropdownOpened: boolean; + parsedData: ComboboxParsedItem[]; } export type PillsInputFactory = Factory<{ @@ -32,8 +36,11 @@ export const PillsInput = factory((_props, ref) => { children, onMouseDown, onClick, + openDropdown, size, disabled, + dropdownOpened, + parsedData, __staticSelector, error, variant, @@ -59,6 +66,9 @@ export const PillsInput = factory((_props, ref) => { event.preventDefault(); onClick?.(event); fieldRef.current?.focus(); + if(!dropdownOpened && parsedData.length > 0) { + openDropdown(); + } }} {...others} multiline diff --git a/packages/@mantine/core/src/components/TagsInput/TagsInput.tsx b/packages/@mantine/core/src/components/TagsInput/TagsInput.tsx index c6787e90f5..331d245651 100644 --- a/packages/@mantine/core/src/components/TagsInput/TagsInput.tsx +++ b/packages/@mantine/core/src/components/TagsInput/TagsInput.tsx @@ -388,6 +388,9 @@ export const TagsInput = factory((_props, ref) => { __stylesApiProps={{ ...props, multiline: true }} id={_id} mod={mod} + openDropdown={combobox.openDropdown} + dropdownOpened={combobox.dropdownOpened} + parsedData={parsedData} > {values}