From 5463f43ba933e7bddcf750150b40c3646206f9ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Thu, 1 Feb 2024 14:21:05 +0800 Subject: [PATCH] chore: fix removeIcon not working (#748) --- src/PickerInput/Selector/SingleSelector/index.tsx | 5 +++++ src/PickerInput/SinglePicker.tsx | 3 +++ tests/multiple.spec.tsx | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/PickerInput/Selector/SingleSelector/index.tsx b/src/PickerInput/Selector/SingleSelector/index.tsx index f2c84f76f..659401370 100644 --- a/src/PickerInput/Selector/SingleSelector/index.tsx +++ b/src/PickerInput/Selector/SingleSelector/index.tsx @@ -30,6 +30,8 @@ export interface SingleSelectorProps // Invalid invalid: boolean; onInvalid: (valid: boolean) => void; + + removeIcon?: React.ReactNode; } function SingleSelector( @@ -98,6 +100,8 @@ function SingleSelector( 'aria-required': ariaRequired, autoFocus, + removeIcon, + ...restProps } = props; @@ -165,6 +169,7 @@ function SingleSelector( formatDate={getText} maxTagCount={maxTagCount} disabled={disabled} + removeIcon={removeIcon} /> /** Not support `time` or `datetime` picker */ multiple?: boolean; + removeIcon?: React.ReactNode; /** Only work when `multiple` is in used */ maxTagCount?: number | 'responsive'; @@ -167,6 +168,7 @@ function Picker( inputReadOnly, suffixIcon, + removeIcon, // Focus onFocus, @@ -620,6 +622,7 @@ function Picker( ref={selectorRef} // Icon suffixIcon={suffixIcon} + removeIcon={removeIcon} // Active activeHelp={!!internalHoverValue} allHelp={!!internalHoverValue && hoverSource === 'preset'} diff --git a/tests/multiple.spec.tsx b/tests/multiple.spec.tsx index 477628f42..f413a7a66 100644 --- a/tests/multiple.spec.tsx +++ b/tests/multiple.spec.tsx @@ -125,4 +125,16 @@ describe('Picker.Multiple', () => { rerender(renderDemo(false)); expect(container.querySelector('.rc-picker-clear')).toBeFalsy(); }); + + it('removeIcon', () => { + const { container } = render( + Remove} + />, + ); + + expect(container.querySelector('.custom-remove')).toBeTruthy(); + }); });