File tree 1 file changed +9
-3
lines changed
packages/clay-core/src/language-picker
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,11 @@ type Props = {
54
54
*/
55
55
defaultActive ?: boolean ;
56
56
57
+ /**
58
+ * The initial selected locale id (uncontrolled).
59
+ */
60
+ defaultSelectedLocaleId ?: React . Key ;
61
+
57
62
/**
58
63
* Flag to hide the text in the trigger.
59
64
*/
@@ -88,7 +93,7 @@ type Props = {
88
93
/**
89
94
* Exposes the currently selected locale id
90
95
*/
91
- selectedLocaleId : string ;
96
+ selectedLocaleId ?: React . Key ;
92
97
93
98
/**
94
99
* Flag to show the picker in small size.
@@ -203,6 +208,7 @@ const ClayLanguagePicker = ({
203
208
active,
204
209
classNamesTrigger,
205
210
defaultActive = false ,
211
+ defaultSelectedLocaleId,
206
212
hideTriggerText,
207
213
id,
208
214
messages = {
@@ -223,8 +229,7 @@ const ClayLanguagePicker = ({
223
229
} : Props ) => {
224
230
const defaultLanguage = locales [ 0 ] ;
225
231
const hasTranslations = Object . keys ( translations ) . length ;
226
- const selectedLocale =
227
- locales . find ( ( { id} ) => id === selectedLocaleId ) || locales [ 0 ] ! ;
232
+ const selectedLocale = locales . find ( ( { id} ) => id === selectedLocaleId ) ! ;
228
233
229
234
return (
230
235
< Picker
@@ -235,6 +240,7 @@ const ClayLanguagePicker = ({
235
240
as = { Trigger }
236
241
classNamesTrigger = { classNamesTrigger }
237
242
defaultActive = { defaultActive }
243
+ defaultSelectedKey = { defaultSelectedLocaleId || locales [ 0 ] ! . id }
238
244
hideTriggerText = { hideTriggerText }
239
245
id = { id }
240
246
items = { locales }
You can’t perform that action at this time.
0 commit comments