diff --git a/api-generator/components/selectbutton.js b/api-generator/components/selectbutton.js index 93a2641ea..6dd55ad81 100644 --- a/api-generator/components/selectbutton.js +++ b/api-generator/components/selectbutton.js @@ -51,6 +51,12 @@ const SelectButtonProps = [ name: 'unselectable', type: 'boolean', default: 'false', + description: 'Whether selection can not be cleared.' + }, + { + name: 'allowEmpty', + type: 'boolean', + default: 'true', description: 'Whether selection can be cleared.' }, { diff --git a/components/lib/selectbutton/BaseSelectButton.vue b/components/lib/selectbutton/BaseSelectButton.vue index 7ea87474c..c2018299f 100644 --- a/components/lib/selectbutton/BaseSelectButton.vue +++ b/components/lib/selectbutton/BaseSelectButton.vue @@ -16,6 +16,10 @@ export default { type: Boolean, default: false }, + allowEmpty: { + type: Boolean, + default: true + }, disabled: Boolean, dataKey: null, 'aria-labelledby': { diff --git a/components/lib/selectbutton/SelectButton.d.ts b/components/lib/selectbutton/SelectButton.d.ts index 3269cd3d5..e8c1a6369 100755 --- a/components/lib/selectbutton/SelectButton.d.ts +++ b/components/lib/selectbutton/SelectButton.d.ts @@ -155,10 +155,16 @@ export interface SelectButtonProps { */ dataKey?: string | undefined; /** - * Whether selection can be cleared. + * Whether selection can not be cleared. * @defaultValue false + * @deprecated Use 'allowEmpty' property instead. */ unselectable?: boolean | undefined; + /** + * Whether selection can be cleared. + * @defaultValue true + */ + allowEmpty?: boolean | undefined; /** * Identifier of the underlying element. */ diff --git a/components/lib/selectbutton/SelectButton.vue b/components/lib/selectbutton/SelectButton.vue index a291fb572..08ea3fc7b 100755 --- a/components/lib/selectbutton/SelectButton.vue +++ b/components/lib/selectbutton/SelectButton.vue @@ -81,7 +81,7 @@ export default { let selected = this.isSelected(option); - if (selected && this.unselectable) { + if (selected && (this.unselectable || !this.allowEmpty)) { return; } diff --git a/doc/common/apidoc/index.json b/doc/common/apidoc/index.json index cb9026aaa..310908af6 100644 --- a/doc/common/apidoc/index.json +++ b/doc/common/apidoc/index.json @@ -42662,6 +42662,15 @@ "readonly": false, "type": "boolean", "default": "false", + "description": "Whether selection can not be cleared.", + "deprecated": "Use 'allowEmpty' property instead." + }, + { + "name": "allowEmpty", + "optional": true, + "readonly": false, + "type": "boolean", + "default": "true", "description": "Whether selection can be cleared." }, {