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

ActionList: Enable focusZone for roles listbox and menu #4795

Merged
merged 6 commits into from
Aug 15, 2024

Conversation

siddharthkp
Copy link
Member

@siddharthkp siddharthkp commented Jul 30, 2024

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@siddharthkp siddharthkp added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Jul 30, 2024
Copy link

changeset-bot bot commented Jul 30, 2024

🦋 Changeset detected

Latest commit: fa13d5a

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

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

@github-actions github-actions bot added the staff Author is a staff member label Jul 30, 2024
Copy link
Contributor

github-actions bot commented Jul 30, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 96.24 KB (+0.05% 🔺)
packages/react/dist/browser.umd.js 96.46 KB (+0.01% 🔺)

@siddharthkp
Copy link
Member Author

siddharthkp commented Jul 30, 2024

Identified some of the failing tests in dotcom as coming from the release candidate. Will wait for next dotcom upgrade before going too deep in debugging

Update: dotcom upgrade was merged, creating integration tests again

@github-actions github-actions bot temporarily deployed to storybook-preview-4795 July 31, 2024 15:51 Inactive
@siddharthkp siddharthkp changed the title ActionList: Enable focusZone for listbox and menu ActionList: Enable focusZone for roles listbox and menu Aug 1, 2024
@siddharthkp siddharthkp added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Aug 1, 2024
@siddharthkp siddharthkp marked this pull request as ready for review August 1, 2024 14:06
@siddharthkp siddharthkp requested a review from a team as a code owner August 1, 2024 14:06
Copy link
Contributor

@TylerJDev TylerJDev left a comment

Choose a reason for hiding this comment

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

LGTM! Few non-blocking comments!

let enableFocusZone = false
if (enableFocusZoneFromContainer !== undefined) enableFocusZone = enableFocusZoneFromContainer
else if (listRole) enableFocusZone = ['menu', 'menubar', 'listbox'].includes(listRole)

useFocusZone({
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we'd want to add focusOutBehavior: 'wrap' by default, or allow consumers to add that themselves?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm wondering if we'd want to add focusOutBehavior: 'wrap' by default

Honestly, not sure, what do you think?

or allow consumers to add that themselves?

That's the part that's missing right now. I think I'd like to wait for feedback/requests before introducing focusZoneSettings like we have on other focus-zoning components

Copy link
Contributor

Choose a reason for hiding this comment

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

For role=menu, we'd definitely want it to wrap by default. With role=listbox there may be cases where it doesn't need to wrap. I'd say if we can conditionally set it to wrap based on if it's a menu or not would be a safe bet, at least for now!

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!


let enableFocusZone = false
if (enableFocusZoneFromContainer !== undefined) enableFocusZone = enableFocusZoneFromContainer
else if (listRole) enableFocusZone = ['menu', 'menubar', 'listbox'].includes(listRole)
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking: I see we have have menubar, I am wondering if there'd be a case where role=menubar is used with ActionList 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't have one yet, but I think it's possible. The issue linked to menu + menubar pattern, so I included it just in case

const listRef = useProvidedRefOrCreate(forwardedRef as React.RefObject<HTMLUListElement>)

let enableFocusZone = false
Copy link
Contributor

Choose a reason for hiding this comment

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

If there's an existing focus zone being used for an ActionList, would the one being used here replace it? I saw an instance where there was an ActionList inside of an AnchoredOverlay that had an implicit focus zone attached:

<AnchoredOverlay
  renderAnchor={props => <Button {...props}>Button</Button>}
  focusZoneSettings={{
    focusOutBehavior: 'wrap',
  }}
>
  <ActionList role="listbox">
    <ActionList.Item>Item 1</ActionList.Item>
    <ActionList.Item>Item 2</ActionList.Item>
  </ActionList>
</AnchoredOverlay>

I'm wondering if this would be an issue or not 🤔. I think the existing cases are rare, so doesn't seem like it would be.

Copy link
Member Author

@siddharthkp siddharthkp Aug 8, 2024

Choose a reason for hiding this comment

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

focus zones can only be additive, not removed. So, if the parent AnchoredOverlay has a focus zone, that would work on all its children. Setting it to false on ActionList would not exclude it from the parent's focus zone.

Tested with ActionMenu, Autocomplete, etc. because they also use AnchoredOverlay (and it's focus zone)

@siddharthkp siddharthkp self-assigned this Aug 8, 2024
@siddharthkp
Copy link
Member Author

Updated focusOutBehavior to wrap, will test with dotcom once again before merging

@siddharthkp siddharthkp removed the integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh label Aug 14, 2024
@primer-integration
Copy link

primer-integration bot commented Aug 14, 2024

👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/337581

Update: Only license job failed, everything else is good to go!

@siddharthkp siddharthkp added this pull request to the merge queue Aug 15, 2024
Merged via the queue into main with commit ca6b4b1 Aug 15, 2024
34 checks passed
@siddharthkp siddharthkp deleted the actionlist-focus-zone-based-on-role branch August 15, 2024 08:08
@primer primer bot mentioned this pull request Aug 15, 2024
@siddharthkp siddharthkp added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Aug 20, 2024
@primer primer bot mentioned this pull request Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh react staff Author is a staff member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants