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

[React] Combobox: aria-labelledby not set if Label is rendered last #1836

Closed
daniel-franz opened this issue Sep 8, 2022 · 2 comments · Fixed by #1838
Closed

[React] Combobox: aria-labelledby not set if Label is rendered last #1836

daniel-franz opened this issue Sep 8, 2022 · 2 comments · Fixed by #1838
Assignees

Comments

@daniel-franz
Copy link

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

v1.7.0

What browser are you using?

Chrome, Jest

Reproduction URL
Minimal failing test-case:

    it(
      'should be possible to link Input/Button and Label if Label is rendered last',
      suppressConsoleLogs(async () => {
        render(
            <Combobox value="Test" onChange={console.log}>
                <Combobox.Input onChange={NOOP} />
                <Combobox.Button />
                <Combobox.Label>Label</Combobox.Label>
            </Combobox>
        )

        assertComboboxLabelLinkedWithCombobox()
        assertComboboxButtonLinkedWithComboboxLabel()
      })
    )

Describe your issue

labelRef does not seem to get updated on Input and Button if the Label is rendered last. This results in missing aria-labelledby attributes. Same as reported in #1352, but it is also failing in React.

The issue is fixing itself when re-rendering the component.

@RobinMalfait
Copy link
Member

Hey! Thank you for your bug report!
Much appreciated! 🙏

This should be fixed by #1838, and will be available in the next release.

You can already try it using npm install @headlessui/react@insiders.

@daniel-franz
Copy link
Author

Hey. It works perfectly. Thank you for fixing it that fast 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants