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

Fix FAQGroup autofocus with Alloy issue #629

Merged
merged 3 commits into from
Jun 26, 2024
Merged

Conversation

stamat
Copy link
Contributor

@stamat stamat commented Jun 26, 2024

Summary

I gated the focus logic via the initialRender ref to move focus on arrow navigation. However, the Alloy actually triggers the render of the FAQGroup component, which causes the initialRender ref to be set to false. This causes the autofocus to the first FAQGroup element and the page is scrolled to it.

This PR changes the logic to gate the focus logic via the hasInteracted state instead of the initialRender ref. This way, the focus logic is only triggered after the user has interacted with the FAQGroup component.

This issue is only present in development environment probably due the Alloy dev setup...

List of notable changes:

  • updated FAQGroupProps type to include hasInteracted state because the focus logic is gated via the hasInteracted state instead of the initialRender ref.

What should reviewers focus on?

This can only be tested on the dotcom pages where the FAQGroup component is used, for instace /features/copilot. Arrow navigation should move the focus correctly and the page should not scroll to the first FAQGroup element on initial render.

Supporting resources (related issues, external links, etc):

Contributor checklist:

  • All new and existing CI checks pass
  • Tests prove that the feature works and covers both happy and unhappy paths
  • Any drop in coverage, breaking changes or regressions have been documented above
  • New visual snapshots have been generated / updated for any UI changes
  • All developer debugging and non-functional logging has been removed
  • Related issues have been referenced in the PR description

Reviewer checklist:

  • Check that pull request and proposed changes adhere to our contribution guidelines and code of conduct
  • Check that tests prove the feature works and covers both happy and unhappy paths
  • Check that there aren't other open Pull Requests for the same update/change

Copy link

changeset-bot bot commented Jun 26, 2024

🦋 Changeset detected

Latest commit: bc3f4f6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@primer/react-brand Patch
@primer/brand-primitives Patch
@primer/brand-e2e Patch
@primer/brand-fonts Patch
@primer/brand-config Patch
@primer/brand-storybook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jun 26, 2024

🟢 No design token changes found

@stamat stamat self-assigned this Jun 26, 2024
Copy link
Contributor

github-actions bot commented Jun 26, 2024

🟢 No visual differences found

Our visual comparison tests did not find any differences in the UI.

@stamat stamat changed the title use interaction gating instead of initialization gating Fix FAQGroup autofocus with Alloy issue Jun 26, 2024
@stamat stamat requested review from joshfarrant and rezrah June 26, 2024 17:18
@stamat stamat marked this pull request as ready for review June 26, 2024 17:20
Copy link
Collaborator

@rezrah rezrah left a comment

Choose a reason for hiding this comment

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

👍

This issue is only present in development environment probably due the Alloy dev setup...

@stamat the change looks fairly context-agnostic to me, so I think it's fine. Just an FYI for future that we don't wanna put dotcom-specific fixes into Primer Brand, as the library is used outside the monolith too.

@stamat stamat merged commit 03237fa into main Jun 26, 2024
17 checks passed
@stamat stamat deleted the stamat/faq-group-a11y-followup branch June 26, 2024 20:12
@primer-css primer-css mentioned this pull request Jun 25, 2024
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.

2 participants