Skip to content

Commit

Permalink
Fix #7333: PickList remove selection after move (#7571)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Jan 6, 2025
1 parent 701f9df commit 1f0e936
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions components/lib/picklist/PickList.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ export const PickList = React.memo(
});
}

onSelectionChange({ originalEvent, value: selectedValue }, 'targetSelection', props.onTargetSelectionChange);
break;

case 'allToTarget':
Expand All @@ -128,7 +127,6 @@ export const PickList = React.memo(
}

selectedValue = [];
onSelectionChange({ originalEvent, value: selectedValue }, 'targetSelection', props.onTargetSelectionChange);

break;

Expand All @@ -142,7 +140,6 @@ export const PickList = React.memo(
});
}

onSelectionChange({ originalEvent, value: selectedValue }, 'sourceSelection', props.onSourceSelectionChange);
break;

case 'allToSource':
Expand All @@ -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);
};

Expand All @@ -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) => {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 1f0e936

Please sign in to comment.