Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(keyboard): add [Tab] support #767

Merged
merged 4 commits into from
Oct 29, 2021
Merged

feat(keyboard): add [Tab] support #767

merged 4 commits into from
Oct 29, 2021

Conversation

ph-fritsche
Copy link
Member

@ph-fritsche ph-fritsche commented Oct 29, 2021

What:

Add support for tabbing per keyboard.

Why:

Missing default behavior.

How:

Took the implementation how to determine the tab destination from userEvent.tab.
The new keyboard behaviorPlugin also selects the whole value if the tab destination is an input or textarea like the browser does.

Checklist:

  • Tests
  • Ready to be merged

Additional information

I'm not sure the focusTrap option is needed (any more).
It was introduced to allow using userEvent.tab with focus-trap-react in jsdom. See #193
But at first glance there is nothing in the implementation of focus-trap that should not work out of the box.
We might be able to remove this option. Then userEvent.tab could be reduced to be a convenience wrapper for userEvent.keyboard('[Tab]').

@ph-fritsche ph-fritsche added this to the userEvent v14 milestone Oct 29, 2021
@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 29, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit d7ead36:

Sandbox Source
userEvent-PR-template Configuration

@codecov
Copy link

codecov bot commented Oct 29, 2021

Codecov Report

Merging #767 (d7ead36) into alpha (9b2ef81) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             alpha      #767   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           64        65    +1     
  Lines         1325      1320    -5     
  Branches       512       508    -4     
=========================================
- Hits          1325      1320    -5     
Impacted Files Coverage Δ
src/keyboard/keyMap.ts 100.00% <ø> (ø)
src/keyboard/plugins/functional.ts 100.00% <100.00%> (ø)
src/tab.ts 100.00% <100.00%> (ø)
src/utils/focus/getTabDestination.ts 100.00% <100.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 9b2ef81...d7ead36. Read the comment docs.

@ph-fritsche ph-fritsche merged commit e39177e into alpha Oct 29, 2021
@ph-fritsche ph-fritsche deleted the tab branch October 29, 2021 07:44
@github-actions
Copy link

🎉 This PR is included in version 14.0.0-alpha.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant