Skip to content

Dynamic selection of react-select parent breaks for empty select and with custom className #90

@tupton

Description

@tupton

Empty selects have a ValueContainer whose class name ends with value-container. This gets picked up by the attribute selector matcher added in #86, which then causes value container to be erroneously treated as the react-select parent.

$0.closest('[class^="css-"][class$="-container"]')
<div class=​"css-1hwfws3 value-container">​…​</div>​

When a select has a value, this is no longer an issue because value-container--has-value becomes the last class in the list and the parent is correctly found:

$0.closest('[class^="css-"][class$="-container"]')
<div class=​"css-1pcexqc-container">​…​</div>​

However, this also breaks if you provide a className to the react-select component because react-select places it at the end.

It seems that we need to make the matcher for the parent only look at the first class in the class attribute value, but I'm unsure if that's possible with contains.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions