From 14e36e42bb6a4a23d0479e4323ae038e50d07259 Mon Sep 17 00:00:00 2001 From: liweijie0812 <674416404@qq.com> Date: Sat, 2 Dec 2023 12:07:54 +0800 Subject: [PATCH] =?UTF-8?q?feat(radio):=20=E7=A9=BA=E6=A0=BC=E9=94=AE?= =?UTF-8?q?=E4=B9=9F=E5=8F=AF=E8=A7=A6=E5=8F=91=E9=80=89=E4=B8=AD=20(#2638?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/radio/useKeyboard.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/radio/useKeyboard.ts b/src/radio/useKeyboard.ts index 4ca5f1f3fc..e96aaeea61 100644 --- a/src/radio/useKeyboard.ts +++ b/src/radio/useKeyboard.ts @@ -1,4 +1,5 @@ import { MutableRefObject, useEffect, ChangeEvent, KeyboardEvent } from 'react'; +import { CHECKED_CODE_REG } from '../_common/js/common'; import { off, on } from '../_util/dom'; /** 键盘操作 */ @@ -7,7 +8,7 @@ export default function useKeyboard( setInnerValue: (value: any, context: { e: ChangeEvent }) => void, ) { const checkRadioInGroup = (e: KeyboardEvent) => { - if (/enter/i.test(e.key) || /enter/i.test(e.code)) { + if (CHECKED_CODE_REG.test(e.key) || CHECKED_CODE_REG.test(e.code)) { const inputNode = (e.target as HTMLElement).querySelector('input'); const data = inputNode?.dataset || {}; if (inputNode.checked && data.allowUncheck) {