From 4d7fc0060e9487fb2c5612d2beef043778d68da7 Mon Sep 17 00:00:00 2001 From: habubey Date: Tue, 10 Oct 2023 17:05:21 +0300 Subject: [PATCH] Fix #5073: SelectButton: Add allowEmpty property --- components/lib/selectbutton/SelectButton.js | 4 ++-- components/lib/selectbutton/SelectButtonBase.js | 1 + components/lib/selectbutton/selectbutton.d.ts | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/lib/selectbutton/SelectButton.js b/components/lib/selectbutton/SelectButton.js index 58624ab55e..28a7b69a07 100644 --- a/components/lib/selectbutton/SelectButton.js +++ b/components/lib/selectbutton/SelectButton.js @@ -1,9 +1,9 @@ import * as React from 'react'; +import { PrimeReactContext } from '../api/Api'; import { Tooltip } from '../tooltip/Tooltip'; import { DomHandler, mergeProps, ObjectUtils } from '../utils/Utils'; import { SelectButtonBase } from './SelectButtonBase'; import { SelectButtonItem } from './SelectButtonItem'; -import { PrimeReactContext } from '../api/Api'; export const SelectButton = React.memo( React.forwardRef((inProps, ref) => { @@ -23,7 +23,7 @@ export const SelectButton = React.memo( let selected = isSelected(event.option); - if (selected && !props.unselectable) { + if (selected && (!props.unselectable || props.allowEmpty)) { return; } diff --git a/components/lib/selectbutton/SelectButtonBase.js b/components/lib/selectbutton/SelectButtonBase.js index 1c45815614..96f336a298 100644 --- a/components/lib/selectbutton/SelectButtonBase.js +++ b/components/lib/selectbutton/SelectButtonBase.js @@ -24,6 +24,7 @@ export const SelectButtonBase = ComponentBase.extend({ tabIndex: null, multiple: false, unselectable: true, + allowEmpty: true, disabled: false, style: null, className: null, diff --git a/components/lib/selectbutton/selectbutton.d.ts b/components/lib/selectbutton/selectbutton.d.ts index c648b2706f..7811e8db4e 100644 --- a/components/lib/selectbutton/selectbutton.d.ts +++ b/components/lib/selectbutton/selectbutton.d.ts @@ -122,6 +122,11 @@ export interface SelectButtonProps extends Omit