From 1f0e936dfe149f6f5234be3a0c60a7058fd6783a Mon Sep 17 00:00:00 2001 From: Melloware Date: Mon, 6 Jan 2025 09:54:53 -0500 Subject: [PATCH] Fix #7333: PickList remove selection after move (#7571) --- components/lib/picklist/PickList.js | 35 +++++++++++++++++++---------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/components/lib/picklist/PickList.js b/components/lib/picklist/PickList.js index ef5408dcdb..b4a3dd01d5 100644 --- a/components/lib/picklist/PickList.js +++ b/components/lib/picklist/PickList.js @@ -114,7 +114,6 @@ export const PickList = React.memo( }); } - onSelectionChange({ originalEvent, value: selectedValue }, 'targetSelection', props.onTargetSelectionChange); break; case 'allToTarget': @@ -128,7 +127,6 @@ export const PickList = React.memo( } selectedValue = []; - onSelectionChange({ originalEvent, value: selectedValue }, 'targetSelection', props.onTargetSelectionChange); break; @@ -142,7 +140,6 @@ export const PickList = React.memo( }); } - onSelectionChange({ originalEvent, value: selectedValue }, 'sourceSelection', props.onSourceSelectionChange); break; case 'allToSource': @@ -156,14 +153,18 @@ export const PickList = React.memo( } selectedValue = []; - - onSelectionChange({ originalEvent, value: selectedValue }, 'sourceSelection', props.onSourceSelectionChange); break; default: break; } + onSelectionChange({ originalEvent, value: selectedValue }, 'sourceSelection', props.onSourceSelectionChange); + onSelectionChange({ originalEvent, value: selectedValue }, 'targetSelection', props.onTargetSelectionChange); + + setTargetSelectionState([]); + setSourceSelectionState([]); + handleChange(event, source, target); }; @@ -185,12 +186,6 @@ export const PickList = React.memo( if (callback) { callback(e); } - - if (ObjectUtils.isNotEmpty(sourceSelection) && stateKey === 'targetSelection') { - setSourceSelectionState([]); - } else if (ObjectUtils.isNotEmpty(targetSelection) && stateKey === 'sourceSelection') { - setTargetSelectionState([]); - } }; const onFilter = (event) => { @@ -359,10 +354,26 @@ export const PickList = React.memo( setTargetSelectionState([...targetList]); } - onSelectionChange({ originalEvent: event, value: [...sourceList] }, isSource ? 'sourceSelection' : 'targetSelection', isSource ? props.onSourceSelectionChange : props.onTargetSelectionChange); + onSelectionChange({ originalEvent: event, value: isSource ? [...sourceList] : [...targetList] }, isSource ? 'sourceSelection' : 'targetSelection', isSource ? props.onSourceSelectionChange : props.onTargetSelectionChange); event.preventDefault(); } + break; + case 'KeyD': + if (event.ctrlKey) { + const isSource = type === 'source'; + + if (isSource) { + setSourceSelectionState([]); + } else { + setTargetSelectionState([]); + } + + onSelectionChange({ originalEvent: event, value: [] }, isSource ? 'sourceSelection' : 'targetSelection', isSource ? props.onSourceSelectionChange : props.onTargetSelectionChange); + event.preventDefault(); + } + + break; default: break; }