Skip to content

Commit 5926fdc

Browse files
authored
fix: fix BaseInput missing ref binding (#102)
1 parent fd1275a commit 5926fdc

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/Input.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
305305
classes={classes}
306306
classNames={classNames}
307307
styles={styles}
308+
ref={holderRef}
308309
>
309310
{getInputElement()}
310311
</BaseInput>

tests/index.test.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,42 @@ describe('Input ref', () => {
454454
expect(errorSpy).not.toHaveBeenCalled();
455455
errorSpy.mockRestore();
456456
});
457+
458+
describe('nativeElement', () => {
459+
it('is input', () => {
460+
const ref = React.createRef<InputRef>();
461+
render(<Input ref={ref} prefixCls="rc-input" />);
462+
expect(ref.current?.nativeElement).toHaveClass('rc-input');
463+
});
464+
465+
it('is affix wrapper', () => {
466+
const ref = React.createRef<InputRef>();
467+
render(
468+
<Input
469+
ref={ref}
470+
prefixCls="rc-input"
471+
prefix={'prefix'}
472+
suffix={'suffix'}
473+
/>,
474+
);
475+
expect(ref.current?.nativeElement).toHaveClass('rc-input-affix-wrapper');
476+
});
477+
478+
it('is group wrapper', () => {
479+
const ref = React.createRef<InputRef>();
480+
render(
481+
<Input
482+
ref={ref}
483+
prefixCls="rc-input"
484+
prefix={'prefix'}
485+
suffix={'suffix'}
486+
addonBefore={'addonBefore'}
487+
addonAfter={'addonAfter'}
488+
/>,
489+
);
490+
expect(ref.current?.nativeElement).toHaveClass('rc-input-group-wrapper');
491+
});
492+
});
457493
});
458494

459495
describe('resolveChange should work', () => {

0 commit comments

Comments
 (0)