From a363bfdf5a4dd622f59415c2964774cd0349dd6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=82=9C=E6=9E=97?= <2910041955@qq.com> Date: Wed, 1 Jan 2025 13:51:32 +0800 Subject: [PATCH] fix: fix BaseInput missing ref binding --- src/Input.tsx | 1 + tests/index.test.tsx | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/Input.tsx b/src/Input.tsx index 4ce793f..06d68db 100644 --- a/src/Input.tsx +++ b/src/Input.tsx @@ -305,6 +305,7 @@ const Input = forwardRef((props, ref) => { classes={classes} classNames={classNames} styles={styles} + ref={holderRef} > {getInputElement()} diff --git a/tests/index.test.tsx b/tests/index.test.tsx index 6daf791..2433677 100644 --- a/tests/index.test.tsx +++ b/tests/index.test.tsx @@ -454,6 +454,42 @@ describe('Input ref', () => { expect(errorSpy).not.toHaveBeenCalled(); errorSpy.mockRestore(); }); + + describe('nativeElement', () => { + it('is input', () => { + const ref = React.createRef(); + render(); + expect(ref.current?.nativeElement).toHaveClass('rc-input'); + }); + + it('is affix wrapper', () => { + const ref = React.createRef(); + render( + , + ); + expect(ref.current?.nativeElement).toHaveClass('rc-input-affix-wrapper'); + }); + + it('is group wrapper', () => { + const ref = React.createRef(); + render( + , + ); + expect(ref.current?.nativeElement).toHaveClass('rc-input-group-wrapper'); + }); + }); }); describe('resolveChange should work', () => {