Skip to content

Ensure anchored components are properly stacked on top of Dialog components #3111

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

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@headlessui-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Render hidden form input fields for `Checkbox`, `Switch` and `RadioGroup` components ([#3095](https://github.com/tailwindlabs/headlessui/pull/3095))
- Ensure the `multiple` prop is typed correctly when passing explicit types to the `Combobox` component ([#3099](https://github.com/tailwindlabs/headlessui/pull/3099))
- Omit `nullable` prop from `Combobox` component ([#3100](https://github.com/tailwindlabs/headlessui/pull/3100))
- Ensure anchored components are properly stacked on top of `Dialog` components ([#3111](https://github.com/tailwindlabs/headlessui/pull/3111))

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ function DialogFn<TTag extends ElementType = typeof DEFAULT_DIALOG_TAG>(
enabled={dialogState === DialogStates.Open}
element={internalDialogRef}
onUpdate={useEvent((message, type) => {
if (type !== 'Dialog') return
if (type !== 'Dialog' && type !== 'Modal') return

match(message, {
[StackMessage.Add]: () => setNestedDialogCount((count) => count + 1),
Expand Down
5 changes: 3 additions & 2 deletions packages/@headlessui-react/src/internal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
type RefProp,
} from '../utils/render'
import { ForcePortalRoot } from './portal-force-root'
import { StackProvider } from './stack-context'

function useScrollLock(
ownerDocument: Document | null,
Expand Down Expand Up @@ -171,7 +172,7 @@ function ModalFn<TTag extends ElementType = typeof DEFAULT_MODAL_TAG>(
}

return (
<>
<StackProvider type="Modal" enabled={enabled} element={internalModalRef}>
<ForcePortalRoot force={true}>
<Portal>
<FocusTrap
Expand Down Expand Up @@ -201,7 +202,7 @@ function ModalFn<TTag extends ElementType = typeof DEFAULT_MODAL_TAG>(
<HoistFormFields>
<MainTreeNode />
</HoistFormFields>
</>
</StackProvider>
)
}

Expand Down