Skip to content

No title id is returned when useDialog and useOverlayTriggerState are used in the same component #5402

@loicplaire

Description

@loicplaire

Provide a general summary of the issue here

We are building an AlertDialog component in our components library using the useDialog, useModalOverlay and useOverlayTriggerState hooks.

It seems, that using useOverlayTriggerState in the same component as useDialog seems to trigger a rerender which causes the titleProps.id to be undefined on the second pass.

This causes accessibility issues as the dialog can't be properly labelled without that id.

🤔 Expected Behavior?

The titleProps.id should not be undefined.

😯 Current Behavior

You can verify this issue in this codesanbox: view in Codesanbox.

In the console, you'll notice that the id is correct on the first pass but undefined on the rerender.

image

💁 Possible Solution

Our current solution is to create a separate child component so that useDialog and useOverlayTriggerState are not used in the same component however this is not ideal.

Is the issue potentially with useSlotId or are we using the hook(s) the wrong way?

Thank you!

🔦 Context

No response

🖥️ Steps to Reproduce

As per the details above, we copied your AlertDialog codesanbox and adapted it to match our implementation: view codesanbox.

Version

3.30.0

What browsers are you seeing the problem on?

Firefox, Chrome, Safari, Microsoft Edge

If other, please specify.

No response

What operating system are you using?

macOS

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions