Skip to content
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

Do not validate options by default in OptionsDropdown #7177

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type ComboboxLikeStylesNames = Exclude<ComboboxStylesNames, 'header' | 'f
export interface ComboboxLikeProps {
/** Data used to generate options */
data?: ComboboxData;

validateOptions?: boolean;
/** Controlled dropdown opened state */
dropdownOpened?: boolean;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ComboboxItem, ComboboxLikeRenderOptionInput, ComboboxParsedItem } from
import { defaultOptionsFilter, FilterOptionsInput } from './default-options-filter';
import { isEmptyComboboxData } from './is-empty-combobox-data';
import { isOptionsGroup } from './is-options-group';
import { validateOptions } from './validate-options';
import { validateOptions as validateOptionsFn } from './validate-options';
import classes from '../Combobox.module.css';

export type OptionsFilter = (input: FilterOptionsInput) => ComboboxParsedItem[];
Expand Down Expand Up @@ -95,6 +95,7 @@ export interface OptionsDropdownProps {
hidden?: boolean;
hiddenWhenEmpty?: boolean;
filterOptions?: boolean;
validateOptions?: boolean;
withCheckIcon?: boolean;
value?: string | string[] | null;
checkIconPosition?: 'left' | 'right';
Expand All @@ -116,6 +117,7 @@ export function OptionsDropdown({
maxDropdownHeight,
withScrollArea = true,
filterOptions = true,
validateOptions = false,
withCheckIcon = false,
value,
checkIconPosition,
Expand All @@ -126,7 +128,9 @@ export function OptionsDropdown({
scrollAreaProps,
'aria-label': ariaLabel,
}: OptionsDropdownProps) {
validateOptions(data);
if (validateOptions) {
validateOptionsFn(data);
}

const shouldFilter = typeof search === 'string';
const filteredData = shouldFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export const MultiSelect = factory<MultiSelectFactory>((_props, ref) => {
required,
mod,
renderOption,
validateOptions,
onRemove,
onClear,
scrollAreaProps,
Expand Down Expand Up @@ -412,6 +413,7 @@ export const MultiSelect = factory<MultiSelectFactory>((_props, ref) => {
withScrollArea={withScrollArea}
maxDropdownHeight={maxDropdownHeight}
filterOptions={searchable}
validateOptions={validateOptions}
value={_value}
checkIconPosition={checkIconPosition}
withCheckIcon={withCheckIcon}
Expand Down
2 changes: 2 additions & 0 deletions packages/@mantine/core/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export const Select = factory<SelectFactory>((_props, ref) => {
clearButtonProps,
hiddenInputProps,
renderOption,
validateOptions,
onClear,
autoComplete,
scrollAreaProps,
Expand Down Expand Up @@ -300,6 +301,7 @@ export const Select = factory<SelectFactory>((_props, ref) => {
withScrollArea={withScrollArea}
maxDropdownHeight={maxDropdownHeight}
filterOptions={searchable && selectedOption?.label !== search}
validateOptions={validateOptions}
value={_value}
checkIconPosition={checkIconPosition}
withCheckIcon={withCheckIcon}
Expand Down