From f475cc3308f9d616026d41bd225715db9e4e079e Mon Sep 17 00:00:00 2001 From: betavs <34408516+betavs@users.noreply.github.com> Date: Sat, 19 Oct 2024 23:10:55 +0800 Subject: [PATCH] fix(input-number): the focus event is still triggered when disabled (#4661) --- src/input-number/hooks/useInputNumber.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/input-number/hooks/useInputNumber.tsx b/src/input-number/hooks/useInputNumber.tsx index 46c9b53017..4a6dbc16aa 100644 --- a/src/input-number/hooks/useInputNumber.tsx +++ b/src/input-number/hooks/useInputNumber.tsx @@ -220,7 +220,7 @@ export default function useInputNumber(props: TdInputNumberProps) { ArrowUp: handleAdd, ArrowDown: handleReduce, }; - const code = e.code || e.key; + const code = (e.code || e.key) as keyof typeof keyEvent; if (keyEvent[code] !== undefined) { keyEvent[code](e); } @@ -248,6 +248,7 @@ export default function useInputNumber(props: TdInputNumberProps) { }; const focus = () => { + if (tDisabled.value || isReadonly.value) return; (inputRef.value as any).focus(); };