Skip to content

Commit 727ce90

Browse files
authored
Merge pull request #27 from AokiApp/yuki-js/replace-select-with-nativeselect
2 parents 3abfb11 + 936b788 commit 727ce90

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

packages/mantine/src/widgets/SelectWidget.tsx

+12-15
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
StrictRJSFSchema,
1010
WidgetProps,
1111
} from '@rjsf/utils';
12-
import { MultiSelect, Select } from '@mantine/core';
12+
import { MultiSelect, NativeSelect } from '@mantine/core';
1313
import { createErrors } from '../utils/createErrors';
1414
import { useFieldContext } from '../templates/FieldTemplate';
1515

@@ -83,28 +83,25 @@ function SelectWidget<T = any, S extends StrictRJSFSchema = RJSFSchema, F extend
8383
/>
8484
);
8585
} else {
86+
const valuedData = (enumOptions || []).map(({ value, label }, i) => {
87+
const disabled = enumDisabled && enumDisabled.indexOf(value) !== -1;
88+
return { value: String(i), label, disabled };
89+
});
90+
const data = [{ value: '-1', label: placeholder || '' }, ...valuedData];
8691
return (
87-
<Select
88-
allowDeselect
89-
checkIconPosition='right'
90-
clearable={!required}
91-
data={(enumOptions || []).map(({ value, label }, i) => {
92-
const disabled = enumDisabled && enumDisabled.indexOf(value) !== -1;
93-
return { value: String(i), label, disabled };
94-
})}
92+
<NativeSelect
93+
data={data}
9594
description={description}
9695
disabled={disabled || readonly}
9796
error={createErrors<T>(rawErrors, hideError)}
9897
label={labelValue(label, hideLabel, false)}
9998
autoFocus={autofocus}
10099
required={required}
101-
searchable
102-
value={selectedIndices as string | null}
103-
onChange={handleChange}
104-
onDropdownClose={handleBlur}
105-
onDropdownOpen={handleFocus}
100+
value={selectedIndices ?? '-1'}
101+
onChange={(event) => handleChange(event.currentTarget.value)}
102+
onFocus={handleFocus}
103+
onBlur={handleBlur}
106104
aria-describedby={ariaDescribedByIds<T>(id)}
107-
placeholder={placeholder}
108105
className='armt-widget-select armt-widget-select-single'
109106
/>
110107
);

0 commit comments

Comments
 (0)