Skip to content

Commit d50c845

Browse files
authored
fix(SelectNext): Accept defaultValue (#390)
1 parent bd5a947 commit d50c845

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/SelectNext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function NonMemoizedNonForwardedSelect<T extends SelectProps.Option[]>(
163163

164164
return {
165165
"defaultValue": isEmptyValueSelected
166-
? ""
166+
? nativeSelectProps?.defaultValue ?? ""
167167
: (() => {
168168
const selectedOption = options.find(option => option.selected);
169169
assert(selectedOption !== undefined);

stories/SelectNext.stories.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,26 @@ export const Default = getStory({
222222
options
223223
});
224224

225+
export const DefaultWithSelectedOption = getStory({
226+
"label": "Label pour liste déroulante",
227+
options: [
228+
...options,
229+
{
230+
"value": "4",
231+
"label": "Option 4",
232+
"selected": true
233+
}
234+
]
235+
});
236+
237+
export const DefaultWithDefaultValue = getStory({
238+
"label": "Label pour liste déroulante",
239+
options,
240+
"nativeSelectProps": {
241+
"defaultValue": "2"
242+
}
243+
});
244+
225245
export const DefaultWithPlaceholder = getStory({
226246
"label": "Label pour liste déroulante",
227247
"placeholder": "Sélectionnez une option",

0 commit comments

Comments
 (0)