Fixed #2826 - SelectButton | new `unselectable` property

pull/2835/head
Tuğçe Küçükoğlu 2022-08-04 17:20:01 +03:00
parent 79803baf11
commit c7243d25dc
4 changed files with 24 additions and 0 deletions

View File

@ -47,6 +47,12 @@ const SelectButtonProps = [
default: "null", default: "null",
description: "A property to uniquely identify an option." description: "A property to uniquely identify an option."
}, },
{
name: "unselectable",
type: "boolean",
default: "true",
description: "Whether selection can be cleared."
},
{ {
name: "aria-labelledby", name: "aria-labelledby",
type: "string", type: "string",

View File

@ -51,6 +51,10 @@ export interface SelectButtonProps {
* A property to uniquely identify an option. * A property to uniquely identify an option.
*/ */
dataKey?: string | undefined; dataKey?: string | undefined;
/**
* Whether selection can be cleared.
*/
unselectable?: boolean | undefined;
/** /**
* Identifier of the underlying element. * Identifier of the underlying element.
*/ */

View File

@ -23,6 +23,10 @@ export default {
optionValue: null, optionValue: null,
optionDisabled: null, optionDisabled: null,
multiple: Boolean, multiple: Boolean,
unselectable: {
type: Boolean,
default: true
},
disabled: Boolean, disabled: Boolean,
dataKey: null, dataKey: null,
'aria-labelledby': { 'aria-labelledby': {
@ -67,6 +71,10 @@ export default {
} }
let selected = this.isSelected(option); let selected = this.isSelected(option);
if (selected && !this.unselectable) {
return;
}
let optionValue = this.getOptionValue(option); let optionValue = this.getOptionValue(option);
let newValue; let newValue;

View File

@ -106,6 +106,12 @@ export default {
<td>false</td> <td>false</td>
<td>When specified, allows selecting multiple values.</td> <td>When specified, allows selecting multiple values.</td>
</tr> </tr>
<tr>
<td>unselectable</td>
<td>boolean</td>
<td>true</td>
<td>Whether selection can be cleared.</td>
</tr>
<tr> <tr>
<td>disabled</td> <td>disabled</td>
<td>boolean</td> <td>boolean</td>