Skip to content

Commit 5463f43

Browse files
authored
chore: fix removeIcon not working (#748)
1 parent a9e41e6 commit 5463f43

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/PickerInput/Selector/SingleSelector/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export interface SingleSelectorProps<DateType extends object = any>
3030
// Invalid
3131
invalid: boolean;
3232
onInvalid: (valid: boolean) => void;
33+
34+
removeIcon?: React.ReactNode;
3335
}
3436

3537
function SingleSelector<DateType extends object = any>(
@@ -98,6 +100,8 @@ function SingleSelector<DateType extends object = any>(
98100
'aria-required': ariaRequired,
99101
autoFocus,
100102

103+
removeIcon,
104+
101105
...restProps
102106
} = props;
103107

@@ -165,6 +169,7 @@ function SingleSelector<DateType extends object = any>(
165169
formatDate={getText}
166170
maxTagCount={maxTagCount}
167171
disabled={disabled}
172+
removeIcon={removeIcon}
168173
/>
169174
<input
170175
className={`${prefixCls}-multiple-input`}

src/PickerInput/SinglePicker.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export interface BasePickerProps<DateType extends object = any>
4141

4242
/** Not support `time` or `datetime` picker */
4343
multiple?: boolean;
44+
removeIcon?: React.ReactNode;
4445
/** Only work when `multiple` is in used */
4546
maxTagCount?: number | 'responsive';
4647

@@ -167,6 +168,7 @@ function Picker<DateType extends object = any>(
167168
inputReadOnly,
168169

169170
suffixIcon,
171+
removeIcon,
170172

171173
// Focus
172174
onFocus,
@@ -620,6 +622,7 @@ function Picker<DateType extends object = any>(
620622
ref={selectorRef}
621623
// Icon
622624
suffixIcon={suffixIcon}
625+
removeIcon={removeIcon}
623626
// Active
624627
activeHelp={!!internalHoverValue}
625628
allHelp={!!internalHoverValue && hoverSource === 'preset'}

tests/multiple.spec.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,16 @@ describe('Picker.Multiple', () => {
125125
rerender(renderDemo(false));
126126
expect(container.querySelector('.rc-picker-clear')).toBeFalsy();
127127
});
128+
129+
it('removeIcon', () => {
130+
const { container } = render(
131+
<DayPicker
132+
multiple
133+
defaultValue={[getDay('2000-01-01')]}
134+
removeIcon={<span className="custom-remove">Remove</span>}
135+
/>,
136+
);
137+
138+
expect(container.querySelector('.custom-remove')).toBeTruthy();
139+
});
128140
});

0 commit comments

Comments
 (0)