Skip to content

Commit 3a2968e

Browse files
authored
fix: styles.affixWrapper didn't work (#44)
1 parent 87d6291 commit 3a2968e

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/BaseInput.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ const BaseInput: FC<BaseInputProps> = (props) => {
116116
element = (
117117
<AffixWrapperComponent
118118
className={affixWrapperCls}
119-
style={!hasAddon(props) ? style : undefined}
119+
style={{
120+
...(!hasAddon(props) ? style : undefined),
121+
...styles?.affixWrapper,
122+
}}
120123
hidden={!hasAddon(props) && hidden}
121124
onClick={onInputClick}
122125
{...dataAttrs?.affixWrapper}

tests/BaseInput.test.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,33 @@ describe('BaseInput', () => {
208208
);
209209
expect(container).toMatchSnapshot();
210210
});
211+
212+
it('styles should work', () => {
213+
const container = render(
214+
<BaseInput
215+
prefixCls="rc-input"
216+
prefix="prefix"
217+
addonBefore="addon"
218+
inputElement={<input />}
219+
styles={{
220+
affixWrapper: {
221+
color: 'red',
222+
},
223+
prefix: {
224+
color: 'blue',
225+
},
226+
}}
227+
/>,
228+
);
229+
230+
expect(
231+
container.container.querySelector<HTMLSpanElement>(
232+
'.rc-input-affix-wrapper',
233+
)?.style.color,
234+
).toBe('red');
235+
expect(
236+
container.container.querySelector<HTMLSpanElement>('.rc-input-prefix')
237+
?.style.color,
238+
).toBe('blue');
239+
});
211240
});

0 commit comments

Comments
 (0)