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

Improve support for nested dialogs #2300

Merged
merged 4 commits into from Apr 23, 2023
Merged

Improve support for nested dialogs #2300

merged 4 commits into from Apr 23, 2023

Conversation

diegohaz
Copy link
Member

@diegohaz diegohaz commented Apr 22, 2023

Closes #2298

This PR adds an example for nested dialogs and fixes two related bugs:

  • When the currently active element becomes inaccessible, the focus is lost to the document.body element. Now we're constantly checking document.activeElement to see if the focus was lost, in which case we move the focus to the dialog element itself.
  • When clicking outside a nested modal dialog, it was also closing the parent dialog. The nested dialog is closed on mousedown, and the parent dialog is closed on subsequent click event. (Clicking on the nested dialog backdrop closes all dialogs #2298)

@vercel
Copy link

vercel bot commented Apr 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ariakit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 23, 2023 0:58am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
reakit ⬜️ Ignored (Inspect) Apr 23, 2023 0:58am

@changeset-bot
Copy link

changeset-bot bot commented Apr 22, 2023

🦋 Changeset detected

Latest commit: e2a4ecf

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

This PR includes changesets to release 3 packages
Name Type
@ariakit/test Patch
@ariakit/react-core Patch
@ariakit/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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 22, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e2a4ecf:

Sandbox Source
Ariakit Configuration

@diegohaz diegohaz merged commit 1b40bc1 into main Apr 23, 2023
15 checks passed
@diegohaz diegohaz deleted the dialog-nested branch April 23, 2023 14:14
@github-actions github-actions bot mentioned this pull request Apr 23, 2023
diegohaz pushed a commit that referenced this pull request Apr 24, 2023
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @ariakit/react@0.1.4

### Patch Changes

- Added support for the `inert` attribute on the `Dialog` component. If
the browser supports `inert`, modal dialogs will now use it rather than
focus trap regions.
([#2301](#2301))

- Fixed nested modal `Dialog` also closing the parent dialog when
clicking outside.
([#2300](#2300))

- Fixed modal `Dialog` eventually losing focus to `document.body`.
([#2300](#2300))

- Fixed `Combobox` with `autoSelect` and `autoComplete` set to `both` or
`inline` where the completion string would lose its selected state.
([#2308](#2308))

- Fixed `Combobox` not processing composition text (like chinese
characters or accents).
([#2308](#2308))

-   Updated dependencies: `@ariakit/react-core@0.1.4`.

## @ariakit/react-core@0.1.4

### Patch Changes

- Added support for the `inert` attribute on the `Dialog` component. If
the browser supports `inert`, modal dialogs will now use it rather than
focus trap regions.
([#2301](#2301))

- Fixed nested modal `Dialog` also closing the parent dialog when
clicking outside.
([#2300](#2300))

- Fixed modal `Dialog` eventually losing focus to `document.body`.
([#2300](#2300))

- Fixed `Combobox` with `autoSelect` and `autoComplete` set to `both` or
`inline` where the completion string would lose its selected state.
([#2308](#2308))

- Fixed `Combobox` not processing composition text (like chinese
characters or accents).
([#2308](#2308))

## @ariakit/test@0.1.3

### Patch Changes

- Added support for elements becoming inaccessible between `mousedown`
and `mouseup` events on the `click` function.
([#2300](#2300))

- Added support for composition text on `type`.
([#2308](#2308))

Co-authored-by: github-actions[bot] <github-actions[bot]@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.

Clicking on the nested dialog backdrop closes all dialogs
1 participant