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

Components: Implement focus return for Dropdown component #2911

Merged
merged 1 commit into from
Oct 9, 2017

Conversation

aduth
Copy link
Member

@aduth aduth commented Oct 6, 2017

This pull request seeks to improve the Dropdown component introduced in #2888 to restore the focus return behavior. After #2888, it is no longer possible to escape out of an inserter using the keyboard alone. With these changes, the Dropdown component now handles the Popover's onClose callback and ensures focus is returned to the toggle leveraging the withFocusReturn higher-order component.

Testing instructions:

  1. Navigate to Gutenberg > New Post
  2. Toggle an inserter
  3. Press escape
  4. Note that the inserter is closed and focus returned to the toggle

@aduth aduth added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Feature] UI Components Impacts or related to the UI component system [Feature] Inserter The main way to insert blocks using the + button in the editing interface labels Oct 6, 2017
@codecov
Copy link

codecov bot commented Oct 6, 2017

Codecov Report

Merging #2911 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2911      +/-   ##
==========================================
+ Coverage   33.92%   33.93%   +0.01%     
==========================================
  Files         193      193              
  Lines        5701     5702       +1     
  Branches     1000     1000              
==========================================
+ Hits         1934     1935       +1     
  Misses       3187     3187              
  Partials      580      580
Impacted Files Coverage Δ
components/dropdown/index.js 87.5% <100%> (+0.83%) ⬆️

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 c80ac15...8436e5c. Read the comment docs.

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM and it tests well.

At first I noticed missing unit test for the use case that is being fixed here. I did some research and discovered that withFocusReturn already has tests which ensure this behavior is working as expected. We may leave it as it is because it seems like an implementation detail.

@aduth aduth force-pushed the update/dropdown-focus-return branch from af83578 to 8436e5c Compare October 9, 2017 13:44
@aduth aduth merged commit aec63ef into master Oct 9, 2017
@aduth aduth deleted the update/dropdown-focus-return branch October 9, 2017 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Inserter The main way to insert blocks using the + button in the editing interface [Feature] UI Components Impacts or related to the UI component system [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants