Skip to content

Commit

Permalink
fix(core): Ensure TagsInput dropdown reopens on input click after clear
Browse files Browse the repository at this point in the history
  • Loading branch information
hsskey committed May 9, 2024
1 parent 44c3ffd commit 3a43d08
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/@mantine/core/src/components/PillsInput/PillsInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -13,6 +14,9 @@ export interface PillsInputProps
__stylesApiProps?: Record<string, any>;
__staticSelector?: string;
multiline?: boolean;
openDropdown: () => void;
dropdownOpened: boolean;
parsedData: ComboboxParsedItem[];
}

export type PillsInputFactory = Factory<{
Expand All @@ -32,8 +36,11 @@ export const PillsInput = factory<PillsInputFactory>((_props, ref) => {
children,
onMouseDown,
onClick,
openDropdown,
size,
disabled,
dropdownOpened,
parsedData,
__staticSelector,
error,
variant,
Expand All @@ -59,6 +66,9 @@ export const PillsInput = factory<PillsInputFactory>((_props, ref) => {
event.preventDefault();
onClick?.(event);
fieldRef.current?.focus();
if(!dropdownOpened && parsedData.length > 0) {
openDropdown();
}
}}
{...others}
multiline
Expand Down
3 changes: 3 additions & 0 deletions packages/@mantine/core/src/components/TagsInput/TagsInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ export const TagsInput = factory<TagsInputFactory>((_props, ref) => {
__stylesApiProps={{ ...props, multiline: true }}
id={_id}
mod={mod}
openDropdown={combobox.openDropdown}
dropdownOpened={combobox.dropdownOpened}
parsedData={parsedData}
>
<Pill.Group disabled={disabled} unstyled={unstyled} {...getStyles('pillsList')}>
{values}
Expand Down

0 comments on commit 3a43d08

Please sign in to comment.