From b29f5a71bccc2ed4aa02a7fbc1bea9263fb223c5 Mon Sep 17 00:00:00 2001 From: melloware Date: Mon, 6 Nov 2023 07:58:23 -0500 Subject: [PATCH] Fix #5247: Multiselect onRemove event --- components/lib/multiselect/MultiSelect.js | 7 +++++++ components/lib/multiselect/MultiSelectBase.js | 1 + components/lib/multiselect/multiselect.d.ts | 20 +++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/components/lib/multiselect/MultiSelect.js b/components/lib/multiselect/MultiSelect.js index c2d041bdf8..c430b6f38a 100644 --- a/components/lib/multiselect/MultiSelect.js +++ b/components/lib/multiselect/MultiSelect.js @@ -481,6 +481,13 @@ export const MultiSelect = React.memo( const removeChip = (event, item) => { const value = props.value.filter((val) => !ObjectUtils.equals(val, item, equalityKey)); + if (props.onRemove) { + props.onRemove({ + originalEvent: event, + value + }); + } + updateModel(event, value, item); }; diff --git a/components/lib/multiselect/MultiSelectBase.js b/components/lib/multiselect/MultiSelectBase.js index 7d614a4f42..46bbbcb783 100644 --- a/components/lib/multiselect/MultiSelectBase.js +++ b/components/lib/multiselect/MultiSelectBase.js @@ -239,6 +239,7 @@ export const MultiSelectBase = ComponentBase.extend({ onFilter: null, onFocus: null, onHide: null, + onRemove: null, onSelectAll: null, onShow: null, optionDisabled: null, diff --git a/components/lib/multiselect/multiselect.d.ts b/components/lib/multiselect/multiselect.d.ts index d8f75a5615..273b31037e 100644 --- a/components/lib/multiselect/multiselect.d.ts +++ b/components/lib/multiselect/multiselect.d.ts @@ -320,6 +320,21 @@ interface MultiSelectChangeEvent { target: MultiSelectChangeTargetOptions; } +/** + * Custom remove event when chip is removed. + * @event + */ +interface MultiSelectRemoveEvent { + /** + * Browser event + */ + originalEvent: React.SyntheticEvent; + /** + * Removed item value + */ + value: any; +} + /** * Custom filter event. * @see {@link MultiSelectProps.onFilter} @@ -709,6 +724,11 @@ export interface MultiSelectProps extends Omit