Skip to content

Dialog Component #8826

Closed
Closed
@joshblack

Description

@joshblack

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();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions