Skip to content

Commit

Permalink
feat: add more props to TransBtn
Browse files Browse the repository at this point in the history
  • Loading branch information
RexSkz committed Sep 19, 2023
1 parent b5fccbd commit 483b803
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 5 additions & 4 deletions docs/examples/custom-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ const clearPath =
' 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h618c35.3 0 64-' +
'28.7 64-64V306c0-35.3-28.7-64-64-64z';

const menuItemSelectedIcon = (props) => {
const { ...p } = props;
return <span style={{ position: 'absolute', right: 0 }}>{p.isSelected ? '🌹' : '☑️'}</span>;
};
const menuItemSelectedIcon = (props) => (
<span style={{ position: 'absolute', right: 0, opacity: props.disabled ? 0.5 : 1 }}>
{props.isSelected ? '🌹' : '☑️'}
</span>
);

const singleItemIcon = (
<span style={{ position: 'absolute', right: '0px' }} role="img" aria-label="rose">
Expand Down
2 changes: 1 addition & 1 deletion src/OptionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, {}> = (_, r
<TransBtn
className={`${itemPrefixCls}-option-state`}
customizeIcon={menuItemSelectedIcon}
customizeIconProps={{ isSelected: selected }}
customizeIconProps={{ ...data, isSelected: selected }}
>
{selected ? '✓' : null}
</TransBtn>
Expand Down
5 changes: 4 additions & 1 deletion tests/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,10 @@ describe('Select.Basic', () => {
/>,
);

expect(menuItemSelectedIcon).toHaveBeenCalledWith({ isSelected: true });
expect(menuItemSelectedIcon).toHaveBeenCalledWith({
value: '1',
isSelected: true,
});
});

it('keyDown & KeyUp event', () => {
Expand Down

0 comments on commit 483b803

Please sign in to comment.