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.

Cannot style wrapper when invalid input is typed

See original GitHub issue

User can type invalid date into the input field. I’d like to control the styling of the wrapper (.react-date-picker__wrapper) whenever such situation occurs. Currently this does not seem to be possible as there’s only native :invalid pseudo-class on the hidden input, which is insufficient as one cannot style parent depending on the state of the child.

Since there’s already .react-date-picker--open class added for the opened state, could there be .react-date-picker--invalid for the invalid state?

Alternatively, adding support for onValid and onInvalid hooks would also provide the ability to implement custom styling.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pjgcommented, Jul 5, 2022

Thanks for the update! Unfortunately lack of browser support for :has() limits its usefulness. I also thought about iterating over all inputs, but that seems a little bit overkill. Ideally react-date-picker should bubble up the invalid class name to the main container element 😉

1reaction
wojtekmajcommented, Sep 27, 2021

Fixed that in make-event-props@1.3.0. This didn’t seem to be a burning issue so we won’t create a patch release just to force-bump make-event-props, but if fresh installs or manually installing said dependency should pick the update up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

invalid - CSS: Cascading Style Sheets - MDN Web Docs
The :invalid CSS pseudo-class represents any , , or other element whose contents fail to validate.
Read more >
CSS highlight label BEFORE an invalid input - Stack Overflow
So if your input is :invalid it will invalidate your fieldset, which you can then reference to style your label.
Read more >
Styling input validation errors - OutSystems
So my goal is to create a tooltip box like error message, instead of directly showing the text below the input (sometimes I...
Read more >
invalid - CSS-Tricks
The :invalid selector allows you to select elements that do not contain valid content, as determined by its type attribute.
Read more >
How to handle invalid user inputs in React forms for UX ...
Even in the case of a single text field, we should wrap the <label> and <input> elements with the <form> element, to allow...
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