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

DataViews: Fix focus loss when removing all filters or resetting #67003

Merged
merged 4 commits into from
Nov 14, 2024

Conversation

ntsekouras
Copy link
Contributor

What?

Fixes: #64697

In DataViews when we remove the last visible filter or resetting the filters the focus is lost.
This PR fixes that by focusing the add filter toggle when we do the above. I'm reusing the same Button for the filters toggle to have the same ref, because based on the visible filters we either render an add filter button or a toggle visibility of current filters one.

Testing Instructions

  1. In any list using DataViews add some filters and then:
    1. remove all of the visible filters
    2. reset filters
  2. Observe that in both cases the focus is not lost and is added back to the add filter button
  3. You can try the above with keyboard navigation too.

@ntsekouras ntsekouras added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] DataViews /packages/dataviews labels Nov 14, 2024
@ntsekouras ntsekouras self-assigned this Nov 14, 2024
Copy link

github-actions bot commented Nov 14, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

Flaky tests detected in 3c4c6bd.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11837588090
📝 Reported issues:

@ntsekouras ntsekouras enabled auto-merge (squash) November 14, 2024 15:57
@ntsekouras ntsekouras merged commit e7f0dc5 into trunk Nov 14, 2024
61 of 62 checks passed
@ntsekouras ntsekouras deleted the fix/dataviews-focus-loss-on-filters-remove branch November 14, 2024 16:30
@github-actions github-actions bot added this to the Gutenberg 19.8 milestone Nov 14, 2024
@afercia
Copy link
Contributor

afercia commented Dec 9, 2024

I'm seeing that probably something has changed in the 'Patterns' list where, at least for me, the filters panel is initially open and thus focusing on useEffect sets initial focus on the FilterVisibilityToggle button. Will create a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] DataViews /packages/dataviews [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataViews: focus lost when removing the last filter
3 participants