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

Handle onAction for DropdownMenu Items #1194

Merged
merged 4 commits into from
Apr 30, 2021
Merged

Conversation

dgreif
Copy link
Member

@dgreif dgreif commented Apr 29, 2021

Refactoring DropdownMenu to use the new onAction callback from ActionList.Item, rather than handling click/key press manually. Also allowing item.onAction to call event.preventDefault(), which will now prevent DropdownMenu from closing and triggering onChange

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

@dgreif dgreif requested a review from VanAnderson April 29, 2021 20:51
@changeset-bot
Copy link

changeset-bot bot commented Apr 29, 2021

🦋 Changeset detected

Latest commit: 47e5770

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

This PR includes changesets to release 1 package
Name Type
@primer/components 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

@vercel
Copy link

vercel bot commented Apr 29, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/primer/primer-components/5p3CbLaaByYaxnsdwGycw98fvLo9
✅ Preview: https://primer-components-git-refactor-dropdown-menu-on-action-primer.vercel.app

@dgreif dgreif force-pushed the refactor-dropdown-menu-on-action branch from e90fa6e to a6d24f9 Compare April 29, 2021 22:08
@vercel vercel bot temporarily deployed to Preview April 29, 2021 22:08 Inactive
@vercel vercel bot temporarily deployed to Preview April 30, 2021 19:08 Inactive
Copy link
Contributor

@VanAnderson VanAnderson left a comment

Choose a reason for hiding this comment

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

Looks great! Basically parallel to the other work and I think the places where you just inlined the callback make the code cleaner that what I had 👍

@vercel vercel bot temporarily deployed to Preview April 30, 2021 19:32 Inactive
@vercel vercel bot temporarily deployed to Preview April 30, 2021 19:38 Inactive
@dgreif dgreif merged commit 84e3c57 into main Apr 30, 2021
@dgreif dgreif deleted the refactor-dropdown-menu-on-action branch April 30, 2021 19:42
@github-actions github-actions bot mentioned this pull request Apr 30, 2021
VanAnderson added a commit that referenced this pull request May 5, 2021
* Action Menu can be a controlled component with open state

* update docs for ActionMenu

* Create pink-lions-suffer.md

* Handle onAction for DropdownMenu Items (#1194)

* useProvidedStateOrCreate

* linter fixes

* update hook doc comment

* Update src/hooks/useProvidedStateOrCreate.ts

Co-authored-by: Dusty Greif <dgreif@users.noreply.github.com>

* useProvidedOrCreateState has better implementation for generics

* useProvidedOrCreateState has better implementation for generics

* make string type explicit

Co-authored-by: Dusty Greif <dgreif@users.noreply.github.com>
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.

None yet

2 participants