Skip to content

fix(pointer): blur activeElement on click outside of focusable#834

Merged
ph-fritsche merged 1 commit intobetafrom
iss-832
Jan 16, 2022
Merged

fix(pointer): blur activeElement on click outside of focusable#834
ph-fritsche merged 1 commit intobetafrom
iss-832

Conversation

@ph-fritsche
Copy link
Copy Markdown
Member

What:

Focus document.body on mousedown outside of focusable.

Why:

Closes #832

// The closest focusable element is focused when a `mousedown` would have been fired.
// Even if there was no `mousedown` because the element was disabled.
// A `mousedown` that preventsDefault cancels this though.

When the mousedown happens (or would have happened) outside of a focusable context,
the focus is moved to document.body.

How:

Blur activeElement when focus helper is called with an element outside of focusable context.

Checklist:

  • Tests
  • Ready to be merged

@ph-fritsche ph-fritsche added this to the userEvent v14 milestone Jan 15, 2022
@codesandbox-ci
Copy link
Copy Markdown

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 e74defe:

Sandbox Source
userEvent-PR-template Configuration
ClickOutside Issue #832

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 15, 2022

Codecov Report

Merging #834 (e74defe) into beta (d35ca69) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              beta      #834   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           81        81           
  Lines         1701      1705    +4     
  Branches       611       618    +7     
=========================================
+ Hits          1701      1705    +4     
Impacted Files Coverage Δ
src/pointer/pointerPress.ts 100.00% <100.00%> (ø)
src/utility/upload.ts 100.00% <100.00%> (ø)
src/utils/focus/focus.ts 100.00% <100.00%> (ø)
src/utils/misc/findClosest.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 d35ca69...e74defe. Read the comment docs.

@ph-fritsche ph-fritsche merged commit d64167c into beta Jan 16, 2022
@ph-fritsche ph-fritsche deleted the iss-832 branch January 16, 2022 23:21
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 14.0.0-beta.8 🎉

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.

When clicking outside input should blur

1 participant