From edd3d672e942c4c19dad01bb1a708848b33aad54 Mon Sep 17 00:00:00 2001 From: Nikita Grevtsov Date: Mon, 8 Jun 2026 18:03:01 +0500 Subject: [PATCH] =?UTF-8?q?fix(InputTextBase):=20=D0=B8=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=BF=D1=80=D0=BE=D0=BA?= =?UTF-8?q?=D0=B8=D0=B4=D1=8B=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=B4=D0=BE=D0=B2=20=D0=B8=D0=BD=D0=BF=D1=83=D1=82?= =?UTF-8?q?=D0=B0=20=D0=B2=20ref?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Input/InputTextBase/InputTextBase.tsx | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/components/Input/InputTextBase/InputTextBase.tsx b/src/components/Input/InputTextBase/InputTextBase.tsx index 9834dead..4809b81e 100644 --- a/src/components/Input/InputTextBase/InputTextBase.tsx +++ b/src/components/Input/InputTextBase/InputTextBase.tsx @@ -176,11 +176,30 @@ export const InputTextBase = memo< [floatLabel, styles.iconSize, styles.iconSizeFloatLabel] ) + const imperativeHandle = useMemo( + () => + new Proxy( + {}, + { + get(_, prop) { + if (prop === 'clear') { + return clear + } + + const input = inputRef.current + const value = input?.[prop as keyof TextInput] + + return typeof value === 'function' ? value.bind(input) : value + }, + } + ) as TextInput, + [clear] + ) + useImperativeHandle( propsInputRef, - () => - inputRef.current ? Object.assign(inputRef.current, { clear }) : null, - [inputRef, clear] + () => (inputRef.current ? imperativeHandle : null), + [imperativeHandle] ) const { makeTestId } = useMakeTestId(