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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(useFocus): support :focus-visible #3254

Merged
merged 2 commits into from Jul 30, 2023
Merged

feat(useFocus): support :focus-visible #3254

merged 2 commits into from Jul 30, 2023

Conversation

onmax
Copy link
Contributor

@onmax onmax commented Jul 25, 2023

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Description

This PR introduces an additional option in the useFocus composable which replicates the :focus-visible behavior from CSS. This enhancement allows for better control over how and when elements receive focus, improving the accessibility and usability of components that use this hook.

In detail, when the focusVisible option is set to true, focus will only be set on an element if the :focus-visible pseudo-class matches. This effectively adds support for the :focus-visible pseudo-class in useFocus.

Additional context

I'd like reviewers to focus on the new test as I think the test is just faking the matches properties which make the test irrelevant.

馃 Generated by Copilot at b8ba143

This pull request adds a new feature and a test case for the useFocus hook. The feature allows the user to enable the focusVisible option, which makes the focused reactive value depend on the :focus-visible pseudo-class of the target element. This improves the accessibility and keyboard navigation of the focus state.

馃 Generated by Copilot at b8ba143

  • Add focusVisible option to useFocus hook to replicate :focus-visible behavior of CSS (link, link)
  • Add test case for useFocus hook with focusVisible option enabled (link)

@antfu antfu changed the title Add :focus-visible support to useFocus feat(useFocus): support :focus-visible Jul 30, 2023
@antfu antfu added this pull request to the merge queue Jul 30, 2023
Merged via the queue into vueuse:main with commit 8032933 Jul 30, 2023
3 checks passed
Sign up for free to 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.

None yet

2 participants