Skip to content

Commit

Permalink
fix: styles.affixWrapper didn't work (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
MadCcc authored Aug 1, 2023
1 parent 87d6291 commit 3a2968e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/BaseInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ const BaseInput: FC<BaseInputProps> = (props) => {
element = (
<AffixWrapperComponent
className={affixWrapperCls}
style={!hasAddon(props) ? style : undefined}
style={{
...(!hasAddon(props) ? style : undefined),
...styles?.affixWrapper,
}}
hidden={!hasAddon(props) && hidden}
onClick={onInputClick}
{...dataAttrs?.affixWrapper}
Expand Down
29 changes: 29 additions & 0 deletions tests/BaseInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,33 @@ describe('BaseInput', () => {
);
expect(container).toMatchSnapshot();
});

it('styles should work', () => {
const container = render(
<BaseInput
prefixCls="rc-input"
prefix="prefix"
addonBefore="addon"
inputElement={<input />}
styles={{
affixWrapper: {
color: 'red',
},
prefix: {
color: 'blue',
},
}}
/>,
);

expect(
container.container.querySelector<HTMLSpanElement>(
'.rc-input-affix-wrapper',
)?.style.color,
).toBe('red');
expect(
container.container.querySelector<HTMLSpanElement>('.rc-input-prefix')
?.style.color,
).toBe('blue');
});
});

0 comments on commit 3a2968e

Please sign in to comment.