-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[@mantine/core] Add openOnFocus prop to Combobox based components (#5893)
#8623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -111,6 +111,9 @@ export interface MultiSelectProps | |||||
|
|
||||||
| /** Clear search value when item is selected */ | ||||||
| clearSearchOnChange?: boolean; | ||||||
|
|
||||||
| /** If set, the dropdown opens when the input receives focus @default `true` */ | ||||||
|
||||||
| /** If set, the dropdown opens when the input receives focus @default `true` */ | |
| /** If set and `searchable` is `true`, the dropdown opens when the input receives focus @default `true` */ |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests for openOnFocus: for a searchable MultiSelect, focusing the input should open the dropdown by default, and should not open when openOnFocus={false} is set.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -97,6 +97,9 @@ export interface SelectProps | |||||
|
|
||||||
| /** If set, the highlighted option is selected when the input loses focus @default `false` */ | ||||||
| autoSelectOnBlur?: boolean; | ||||||
|
|
||||||
| /** If set, the dropdown opens when the input receives focus @default `true` */ | ||||||
|
||||||
| /** If set, the dropdown opens when the input receives focus @default `true` */ | |
| /** If set, the dropdown opens when the input receives focus, but only when `searchable` is enabled @default `true` */ |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests for openOnFocus: for a searchable Select, focusing the input should open the dropdown by default, and should not open when openOnFocus={false} is set.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,6 +106,9 @@ export interface TagsInputProps | |
|
|
||
| /** Custom function to determine if a tag is duplicate. Accepts tag value and array of current values. By default, checks if the tag exists case-insensitively. */ | ||
| isDuplicate?: (value: string, currentValues: string[]) => boolean; | ||
|
|
||
| /** If set, the dropdown opens when the input receives focus @default `true` */ | ||
| openOnFocus?: boolean; | ||
| } | ||
|
|
||
| export type TagsInputFactory = Factory<{ | ||
|
|
@@ -119,6 +122,7 @@ const defaultProps = { | |
| acceptValueOnBlur: true, | ||
| splitChars: [','], | ||
| hiddenInputValuesDivider: ',', | ||
| openOnFocus: true, | ||
| size: 'sm', | ||
| } satisfies Partial<TagsInputProps>; | ||
|
|
||
|
|
@@ -197,6 +201,7 @@ export const TagsInput = factory<TagsInputFactory>((_props, ref) => { | |
| scrollAreaProps, | ||
| acceptValueOnBlur, | ||
| isDuplicate, | ||
| openOnFocus, | ||
| attributes, | ||
| ...others | ||
| } = props; | ||
|
|
@@ -457,7 +462,7 @@ export const TagsInput = factory<TagsInputFactory>((_props, ref) => { | |
| onKeyDown={handleInputKeydown} | ||
| onFocus={(event) => { | ||
| onFocus?.(event); | ||
| combobox.openDropdown(); | ||
| openOnFocus && combobox.openDropdown(); | ||
| }} | ||
|
Comment on lines
463
to
466
|
||
| onBlur={(event) => { | ||
| onBlur?.(event); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests for the new
openOnFocusprop: by default focusing the input should open the dropdown, andopenOnFocus={false}should prevent opening on focus.