Skip to content

Can not click on dropdown labels when the dropdown is inside Field #1699

@wojciechsura

Description

@wojciechsura

What component (if applicable)

Describe the bug
If you place a Dropdown inside Field, the label in dropdown items is not clickable. I'm using the Catalyst library, but I'm pretty sure the problem is actually inside Headless.

For more context, in my project I have "extended" inputs, which have prefixes and postfixes and looks like following:

Image

I need to make the dropdown placed in the "postfix" area to work. However, I've figured out that you may place the dropdown anywhere within the Field component and the bug is reproducible.

To Reproduce
Steps to reproduce the behavior:

  1. Create a React project with Tailwind and Catalyst
  2. Create a component containing the following:
import './App.css'
import { Field, FieldGroup, Fieldset } from './lib/catalyst/fieldset'
import { Dropdown, DropdownButton, DropdownItem, DropdownLabel, DropdownMenu } from './lib/catalyst/dropdown'

function App() {
  return (
      <>
          <Fieldset>
              <FieldGroup>
                  <Field>
                      <Dropdown>
                          <DropdownButton>Dropdown</DropdownButton>
                          <DropdownMenu>
                              <DropdownItem onClick={() => alert(1)}>
                                <DropdownLabel>Label</DropdownLabel>
                              </DropdownItem>
                          </DropdownMenu>
                      </Dropdown>
                  </Field>
            </FieldGroup>
          </Fieldset>
    </>
  )
}

export default App

Expected behavior
When you click on the label part of dropdown item, it should react (in the above case, show an alert). It does not. It works though if you click the non-label part of the dropdown item (e.g. right to the text)

Screenshots

Image

Browser/Device (if applicable)

  • OS: Windows 11
  • Browser Chrome
  • Version 136.0.7103.93

Additional context
It may have to do with the fact that the label has an attribute data-slot="label". I guess the Headless' Field component introduces some behavior or CSS for such children, which prevents the dropdown's label to be clickable.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions