From f14fcd6b7c86966d797766451534914471202082 Mon Sep 17 00:00:00 2001 From: Brahma Teja Ponnuru Date: Wed, 16 Oct 2024 17:16:41 +0530 Subject: [PATCH] Prevent deleting selected items when hit backspace in hideSelected Mode When we pass the hideSelectedList as true and hit backspace it is deleting the selected values, Modified the code to prvent it --- src/multiselect/multiselect.component.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/multiselect/multiselect.component.tsx b/src/multiselect/multiselect.component.tsx index 517765f..ef69fd0 100644 --- a/src/multiselect/multiselect.component.tsx +++ b/src/multiselect/multiselect.component.tsx @@ -55,7 +55,8 @@ export class Multiselect extends React.Component { showCheckbox: props.showCheckbox, keepSearchTerm: props.keepSearchTerm, groupedObject: [], - closeIconType: closeIconTypes[props.closeIcon] || closeIconTypes['circle'] + closeIconType: closeIconTypes[props.closeIcon] || closeIconTypes['circle'], + hideSelectedList: props.hideSelectedList, }; // @ts-ignore this.optionTimeout = null; @@ -254,10 +255,11 @@ export class Multiselect extends React.Component { highlightOption, toggleOptionsList, inputValue, - selectedValues + selectedValues, + hideSelectedList } = this.state; const { disablePreSelectedValues } = this.props; - if (e.keyCode === 8 && !inputValue && !disablePreSelectedValues && selectedValues.length) { + if (e.keyCode === 8 && !inputValue && !disablePreSelectedValues && selectedValues.length && !hideSelectedList) { this.onRemoveSelectedItem(selectedValues.length - 1); } if (!options.length) {