From 90ee08746a857defbbe90874c7889aeff915d3f3 Mon Sep 17 00:00:00 2001 From: LiJun Date: Sat, 29 Jan 2022 16:59:43 +0800 Subject: [PATCH 1/3] fix: input in menu can not move cursor by arrow keys --- src/hooks/useAccessibility.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/hooks/useAccessibility.ts b/src/hooks/useAccessibility.ts index b60b27bf..b53f05bd 100644 --- a/src/hooks/useAccessibility.ts +++ b/src/hooks/useAccessibility.ts @@ -263,8 +263,11 @@ export default function useAccessibility( return; } - // Arrow prevent default to avoid page scroll - if (ArrowKeys.includes(which) || [HOME, END].includes(which)) { + // Arrow prevent default to avoid page scroll, not apply for input and textarea + if ( + (ArrowKeys.includes(which) || [HOME, END].includes(which)) && + !['INPUT', 'TEXTAREA'].includes(e.target.nodeType) + ) { e.preventDefault(); } From 6f9970098f3773d0d0293925c6164331c9146514 Mon Sep 17 00:00:00 2001 From: LiJun Date: Sun, 30 Jan 2022 23:34:20 +0800 Subject: [PATCH 2/3] fix: type warning and wrong porperty --- src/hooks/useAccessibility.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useAccessibility.ts b/src/hooks/useAccessibility.ts index b53f05bd..9e3bc77a 100644 --- a/src/hooks/useAccessibility.ts +++ b/src/hooks/useAccessibility.ts @@ -266,7 +266,7 @@ export default function useAccessibility( // Arrow prevent default to avoid page scroll, not apply for input and textarea if ( (ArrowKeys.includes(which) || [HOME, END].includes(which)) && - !['INPUT', 'TEXTAREA'].includes(e.target.nodeType) + !['INPUT', 'TEXTAREA'].includes((e.target as Element).nodeName) ) { e.preventDefault(); } From c2b8d0a37c32a7f2df7b38881ee76513cfdd6b25 Mon Sep 17 00:00:00 2001 From: LiJun Date: Mon, 31 Jan 2022 16:00:39 +0800 Subject: [PATCH 3/3] add test case for cursor move --- tests/Menu.spec.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/Menu.spec.js b/tests/Menu.spec.js index a9a803f1..6da2e5c6 100644 --- a/tests/Menu.spec.js +++ b/tests/Menu.spec.js @@ -435,6 +435,37 @@ describe('Menu', () => { expect(wrapper.isActive(1)).toBeTruthy(); }); + it('input and textarea cursor can be moved by arrow', () => { + const wrapper = mount( + + + + + +