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

Dialog Component #8826

Closed
joshblack opened this issue Jun 1, 2021 · 0 comments
Closed

Dialog Component #8826

joshblack opened this issue Jun 1, 2021 · 0 comments
Labels
package: react carbon-components-react

Comments

@joshblack
Copy link
Contributor

joshblack commented Jun 1, 2021

About

<Dialog> is a primitive used to create modal and non-modal dialogs.

Accessibility

  • When dialog is activated focus is moved to the dialog.
  • Default initial focus is on the first interactive element in the dialog.
  • The dialog should have an accessible name and announce itself as a "dialog".
  • The dialog should be dismissable by
    • activating a "close" button inside the dialog
    • pressing the escape key
    • blurring the dialog by clicking or tapping outside of it
  • If the dialog is modal obscured contents should be inert and inaccessible via keyboard and virtual cursor by constraining focus to the dialog in a "ring".
  • If the dialog is non-modal keyboard and virtual cursor focus is not constrained to the dialog and can leave the dialog causing it to close.
  • When the dialog is closed focus should return to the triggering element unless the dialog is non-modal and was closed by focus or virtual cursor leaving the dialog.

Links & Resources

API Design

function Demo() {
  const [open, setOpen] = useState(false);
  return (
    <Button onClick={() => setOpen(true)}>Open Dialog</Button>
    <Dialog open={open} onDismiss={() => setOpen(false)}>
      {children}
    </Dialog>
  );
}

Props

Name Type Description
children Node
modal boolean Specify if the dialog is a modal or non-modal dialog
onDismiss Function
open boolean
initialFocusRef Object A ref for the node that is focused when the dialog is opened

Links & Resources

Requirements

  • Both modal and nonmodal dialogs are supported
  • TODO

Open issues

Explorations

useDialog hook

function Demo() {
  const { open, close } = useDialog();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: react carbon-components-react
Projects
Archived in project
Development

No branches or pull requests

2 participants