File tree Expand file tree Collapse file tree 6 files changed +32
-15
lines changed
Expand file tree Collapse file tree 6 files changed +32
-15
lines changed Original file line number Diff line number Diff line change @@ -3221,14 +3221,14 @@ None.
32213221
32223222### Props
32233223
3224- | Prop name | Required | Kind | Reactive | Type | Default value | Description |
3225- | :-------- | :------- | :--------------- | :------- | --------------------------------- | ---------------------- | ----------------------------------------- |
3226- | value | No | <code >let</code > | No | <code >string | ; number</code > | <code >""</code > | Specify the option value |
3227- | text | No | <code >let</code > | No | <code >string</code > | <code >"" </code > | Specify the option text |
3228- | hidden | No | <code >let</code > | No | <code >boolean</code > | <code >false</code > | Set to ` true ` to hide the option |
3229- | disabled | No | <code >let</code > | No | <code >boolean</code > | <code >false</code > | Set to ` true ` to disable the option |
3230- | class | No | <code >let</code > | No | <code >string</code > | <code >undefined</code > | Specify the class of the ` option ` element |
3231- | style | No | <code >let</code > | No | <code >string</code > | <code >undefined</code > | Specify the style of the ` option ` element |
3224+ | Prop name | Required | Kind | Reactive | Type | Default value | Description |
3225+ | :-------- | :------- | :--------------- | :------- | --------------------------------- | ---------------------- | ---------------------------------------------------------------------------------- |
3226+ | value | No | <code >let</code > | No | <code >string | ; number</code > | <code >""</code > | Specify the option value |
3227+ | text | No | <code >let</code > | No | <code >string</code > | <code >undefined </code > | Specify the option text< br />If not specified, the value will be used as the text. |
3228+ | hidden | No | <code >let</code > | No | <code >boolean</code > | <code >false</code > | Set to ` true ` to hide the option |
3229+ | disabled | No | <code >let</code > | No | <code >boolean</code > | <code >false</code > | Set to ` true ` to disable the option |
3230+ | class | No | <code >let</code > | No | <code >string</code > | <code >undefined</code > | Specify the class of the ` option ` element |
3231+ | style | No | <code >let</code > | No | <code >string</code > | <code >undefined</code > | Specify the style of the ` option ` element |
32323232
32333233### Slots
32343234
Original file line number Diff line number Diff line change 1253112531 {
1253212532 "name" : " text" ,
1253312533 "kind" : " let" ,
12534- "description" : " Specify the option text" ,
12534+ "description" : " Specify the option text\n If not specified, the value will be used as the text. " ,
1253512535 "type" : " string" ,
12536- "value" : " \"\" " ,
1253712536 "isFunction" : false ,
1253812537 "isFunctionDeclaration" : false ,
1253912538 "isRequired" : false ,
Original file line number Diff line number Diff line change 55 */
66 export let value = " " ;
77
8- /** Specify the option text */
9- export let text = " " ;
8+ /**
9+ * Specify the option text
10+ * If not specified, the value will be used as the text.
11+ * @type {string}
12+ */
13+ export let text = undefined ;
1014
1115 /** Set to `true` to hide the option */
1216 export let hidden = false ;
Original file line number Diff line number Diff line change 77 <SelectItem value ={0 } text =" Zero" />
88 <SelectItem value ={1 } text =" One" />
99</Select >
10+
11+ <Select labelText =" Undefined text" >
12+ <SelectItem value ={2 } />
13+ <SelectItem value ={0 } text =" Zero" />
14+ <SelectItem value ={1 } text =" One" />
15+ </Select >
Original file line number Diff line number Diff line change @@ -240,10 +240,17 @@ describe("Select", () => {
240240 expect ( skeleton . children [ 0 ] ) . toHaveClass ( "bx--skeleton" ) ;
241241 } ) ;
242242
243- it ( "renders value if `text` is falsy " , ( ) => {
243+ it ( "renders `text` instead of ` value` if `text` is an empty string " , ( ) => {
244244 render ( SelectFalsy ) ;
245245
246246 expect ( screen . getByLabelText ( "Falsy text" ) ) . toHaveValue ( "-1" ) ;
247- expect ( screen . getByDisplayValue ( "" ) ) . toBeInTheDocument ( ) ;
247+ expect ( screen . getByRole ( "option" , { name : "" } ) ) . toBeInTheDocument ( ) ;
248+ } ) ;
249+
250+ it ( "renders value if `text` is undefined" , ( ) => {
251+ render ( SelectFalsy ) ;
252+
253+ expect ( screen . getByLabelText ( "Undefined text" ) ) . toHaveValue ( "2" ) ;
254+ expect ( screen . getByRole ( "option" , { name : "2" } ) ) . toBeInTheDocument ( ) ;
248255 } ) ;
249256} ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ export type SelectItemProps = {
99
1010 /**
1111 * Specify the option text
12- * @default ""
12+ * If not specified, the value will be used as the text.
13+ * @default undefined
1314 */
1415 text ?: string ;
1516
You can’t perform that action at this time.
0 commit comments