Skip to content

Commit

Permalink
chore: fix removeIcon not working (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ authored Feb 1, 2024
1 parent a9e41e6 commit 5463f43
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/PickerInput/Selector/SingleSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface SingleSelectorProps<DateType extends object = any>
// Invalid
invalid: boolean;
onInvalid: (valid: boolean) => void;

removeIcon?: React.ReactNode;
}

function SingleSelector<DateType extends object = any>(
Expand Down Expand Up @@ -98,6 +100,8 @@ function SingleSelector<DateType extends object = any>(
'aria-required': ariaRequired,
autoFocus,

removeIcon,

...restProps
} = props;

Expand Down Expand Up @@ -165,6 +169,7 @@ function SingleSelector<DateType extends object = any>(
formatDate={getText}
maxTagCount={maxTagCount}
disabled={disabled}
removeIcon={removeIcon}
/>
<input
className={`${prefixCls}-multiple-input`}
Expand Down
3 changes: 3 additions & 0 deletions src/PickerInput/SinglePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface BasePickerProps<DateType extends object = any>

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

Expand Down Expand Up @@ -167,6 +168,7 @@ function Picker<DateType extends object = any>(
inputReadOnly,

suffixIcon,
removeIcon,

// Focus
onFocus,
Expand Down Expand Up @@ -620,6 +622,7 @@ function Picker<DateType extends object = any>(
ref={selectorRef}
// Icon
suffixIcon={suffixIcon}
removeIcon={removeIcon}
// Active
activeHelp={!!internalHoverValue}
allHelp={!!internalHoverValue && hoverSource === 'preset'}
Expand Down
12 changes: 12 additions & 0 deletions tests/multiple.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,16 @@ describe('Picker.Multiple', () => {
rerender(renderDemo(false));
expect(container.querySelector('.rc-picker-clear')).toBeFalsy();
});

it('removeIcon', () => {
const { container } = render(
<DayPicker
multiple
defaultValue={[getDay('2000-01-01')]}
removeIcon={<span className="custom-remove">Remove</span>}
/>,
);

expect(container.querySelector('.custom-remove')).toBeTruthy();
});
});

0 comments on commit 5463f43

Please sign in to comment.