question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
romgaincommented, Apr 7, 2022

Done, this is reverted in v5.5.0

Thanks again for reporting this @tupton !

1reaction
th3fallencommented, Apr 5, 2022

ahhh, it may be for the best to revert it for now, and I can revisit it and add tests for those cases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Styles - React Select
React Select offers 3 main APIs for styling: The styles prop; The classNames prop; The classNamePrefix prop. The styles prop. The recommended way...
Read more >
React Js conditionally applying class attributes - Stack Overflow
The curly braces are inside the string, so it is being evaluated as string. They need to be outside, so this should work:...
Read more >
Select - Ant Design
Select component to select value from options. When To Use. A dropdown menu for displaying choices - an elegant alternative to the native...
Read more >
How to set default value in select using ReactJS
In HTML, the 'selected' attribute in the option tag is used to set the default value in ... Approach 1: Without using React...
Read more >
How To Style React Components | DigitalOcean
In this tutorial, you'll learn three different ways to style React components: plain Cascading Style Sheets (CSS), inline styles with ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found