Skip to content

Commit

Permalink
Fix ambigious clearing behaviour on SelectButton (#4107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Coretteket authored Oct 9, 2023
1 parent 0a08c56 commit b666789
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
6 changes: 6 additions & 0 deletions api-generator/components/selectbutton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
},
{
Expand Down
4 changes: 4 additions & 0 deletions components/lib/selectbutton/BaseSelectButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export default {
type: Boolean,
default: false
},
allowEmpty: {
type: Boolean,
default: true
},
disabled: Boolean,
dataKey: null,
'aria-labelledby': {
Expand Down
8 changes: 7 additions & 1 deletion components/lib/selectbutton/SelectButton.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/selectbutton/SelectButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default {
let selected = this.isSelected(option);
if (selected && this.unselectable) {
if (selected && (this.unselectable || !this.allowEmpty)) {
return;
}
Expand Down
9 changes: 9 additions & 0 deletions doc/common/apidoc/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
},
{
Expand Down

0 comments on commit b666789

Please sign in to comment.