Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ambigious clearing behaviour on SelectButton #4107

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -27,6 +27,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 @@ -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.
*/
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 @@ -80,7 +80,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 @@ -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."
},
{
Expand Down