Skip to content

fix: input in menu can not move cursor by arrow keys - #434

Open
daskyrk wants to merge 3 commits into
react-component:masterfrom
daskyrk:hotfix/input-in-menu
Open

fix: input in menu can not move cursor by arrow keys#434
daskyrk wants to merge 3 commits into
react-component:masterfrom
daskyrk:hotfix/input-in-menu

Conversation

@daskyrk

Copy link
Copy Markdown

Issue demo:
https://codesandbox.io/s/ji-ben-antd-4-18-5-forked-orrdd?file=/index.js

Have tried to add test case, but not success to simulate keyDown event(official issue):

it('input and textarea cursor can be moved by arrow',()=>{constwrapper=mount(<inputvalue='123'onFocus={e=>e.target}/>,);constinput=wrapper.find('input');input.simulate('focus');constinputNode=input.getDOMNode();expect(inputNode.selectionStart).toEqual(0);input.simulate('keyDown',{which: KeyCode.A,keyCode: KeyCode.A});expect(inputNode.value).toEqual('123A');expect(inputNode.selectionStart).toEqual(1);input.simulate('keyDown',{which: KeyCode.LEFT});expect(inputNode.selectionStart).toEqual(0);consttextarea=wrapper.find('textarea');textarea.simulate('click');expect(textarea.selectionStart).toEqual(0);wrapper.find('Overflow').simulate('keyDown',{which: KeyCode.RIGHT});expect(textarea.selectionStart).toEqual(1);wrapper.find('Overflow').simulate('keyDown',{which: KeyCode.LEFT});expect(textarea.selectionStart).toEqual(0);});

@codecov

codecovBot commented Jan 29, 2022

Copy link
Copy Markdown

Codecov Report

Merging #434 (6f99700) into master (7b56f09) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 6f99700 differs from pull request most recent head c2b8d0a. Consider uploading reports for the commit c2b8d0a to get more accurate results
Impacted file tree graph

@@ Coverage Diff @@## master #434 +/- ##
=======================================
Coverage 99.84% 99.84% =======================================
Files 25 25 Lines 651 654 +3 Branches 169 171 +2 =======================================
+ Hits 650 653 +3 
Misses 1 1 
Impacted FilesCoverage Δ
src/hooks/useAccessibility.ts100.00% <100.00%> (ø)
src/Menu.tsx100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7b56f09...c2b8d0a. Read the comment docs.

@afc163

Copy link
Copy Markdown
Member

图片

@afc163

Copy link
Copy Markdown
Member

Could you add test case?

@daskyrk

Copy link
Copy Markdown
Author

Could you add test case?

Don't know how to simulate keyDown event, the code above not work, do you have any suggestions?

@delete-merged-branch
delete-merged-branchBot deleted the branch react-component:masterMarch 31, 2023 07:09
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@daskyrk@afc163