From 3134e6bb6b3ddcea0091f116b5d9478e35c22560 Mon Sep 17 00:00:00 2001 From: Quinten Coret Date: Tue, 4 Jul 2023 16:24:31 +0200 Subject: [PATCH] Fix ambigious clearing behaviour on SelectButton --- api-generator/components/selectbutton.js | 6 ++++++ components/lib/selectbutton/BaseSelectButton.vue | 4 ++++ components/lib/selectbutton/SelectButton.d.ts | 8 +++++++- components/lib/selectbutton/SelectButton.vue | 2 +- doc/common/apidoc/index.json | 9 +++++++++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/api-generator/components/selectbutton.js b/api-generator/components/selectbutton.js index 483b4541fa..33115d6af1 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 9962035426..27efb4656f 100644 --- a/components/lib/selectbutton/BaseSelectButton.vue +++ b/components/lib/selectbutton/BaseSelectButton.vue @@ -27,6 +27,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 ea3058fb4c..219ee510b9 100755 --- a/components/lib/selectbutton/SelectButton.d.ts +++ b/components/lib/selectbutton/SelectButton.d.ts @@ -127,10 +127,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 b28da92585..c5a185c6f6 100755 --- a/components/lib/selectbutton/SelectButton.vue +++ b/components/lib/selectbutton/SelectButton.vue @@ -80,7 +80,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 57e583a8ca..1e3e7d4f6a 100644 --- a/doc/common/apidoc/index.json +++ b/doc/common/apidoc/index.json @@ -33025,6 +33025,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." }, {