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

TreeView: Create ErrorDialog component #2452

Merged
merged 8 commits into from
Oct 20, 2022
Merged

Conversation

colebemis
Copy link
Contributor

@colebemis colebemis commented Oct 18, 2022

Problems

  • Consumers have to make a lot of micro-decisions when using ConfirmationDialog with TreeView:

    <ConfirmationDialog
      title="Error" // Choose an appropriate title
      confirmButtonContent="Retry" // Choose appropriate CTAs
      cancelButtonContent="Dismiss"
      onClose={gesture => { // Handle onClose event correctly
        setError(null)
    
        if (gesture === 'confirm') {
           loadItems()
        } else {
           setIsExpanded(false)
        }
     }}
     >
      {error.message}
    </ConfirmationDialog>
  • Keyboard events bubble up to the TreeView item when Dialog is open, causing items to expand and collapse unexpectedly.

  • Focus is lost when closing the Dialog:

CleanShot.2022-10-19.at.18.22.28.mp4

Solutions

This PR adds a TreeView.ErrorDialog component to wrap ConfirmationDialog and provide additional focus and event management.

👉 Try it out

<TreeView.ErrorDialog
  onRetry={() => ...}
  onDismiss={() => ...}
>
  {error.message}
</TreeView.ErrorDialog>

Focus is properly moved the parent item when a dialog closes:

CleanShot.2022-10-19.at.18.29.45.mp4

Merge checklist

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

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@changeset-bot
Copy link

changeset-bot bot commented Oct 18, 2022

🦋 Changeset detected

Latest commit: 182bec9

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

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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 18, 2022

size-limit report 📦

Path Size
dist/browser.esm.js 77.99 KB (0%)
dist/browser.umd.js 78.64 KB (0%)

@colebemis colebemis temporarily deployed to github-pages October 18, 2022 23:27 Inactive
@colebemis colebemis temporarily deployed to github-pages October 20, 2022 00:45 Inactive
@colebemis colebemis temporarily deployed to github-pages October 20, 2022 01:02 Inactive
@colebemis colebemis temporarily deployed to github-pages October 20, 2022 01:16 Inactive
@colebemis colebemis marked this pull request as ready for review October 20, 2022 01:37
@colebemis colebemis requested review from a team and rezrah October 20, 2022 01:37
@colebemis colebemis temporarily deployed to github-pages October 20, 2022 01:39 Inactive
Copy link
Member

@joshblack joshblack 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! Love the API

@colebemis colebemis temporarily deployed to github-pages October 20, 2022 21:49 Inactive
@colebemis colebemis merged commit aca96c0 into main Oct 20, 2022
@colebemis colebemis deleted the treeview-error-dialog branch October 20, 2022 21:52
@primer-css primer-css mentioned this pull request Oct 20, 2022
josepmartins pushed a commit that referenced this pull request Oct 21, 2022
* Create TreeView.ErrorDialog component

* Fix icon size

* Add error dialog tests

* Update docs

* Create tough-lobsters-greet.md

* Remove settimeout from test
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