Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
fixing #4777.
also mentioned in #91138, more on that later.
SuperDatePicker
was crashing due totoAbsoluteString
callingtoISOString
on an invalid date. I've usedmoment
's validity check to prevent this from happening and return a flag of"invalid_date"
instead. the consumer can then decide how to handle this situation.I've tried to mimic another error case that was handled before (negative numbers are not allowed) in order to maintain the same UX choices. So, if the value from
toAbsoluteString
is"invalid_date"
I have added an error message under the input field to imply to the user what is wrong with his input and added anInvalid Date
label to thepretty_duration
output in that case.note: this change will prevent
super_date_picker
from crashing but a piece of code in Kibana repeats the same mistake by callingtoISOString
on an invalid date (which causes #91138). both cases must be resolved in order to completely prevent Kibana from crashing.this PR is the first step and I can open another PR in Kibana to fix the error there.
Before:
super_date_picker_crash.mp4
After:
super_date_picker_fix.mp4
Checklist
Check against all themes for compatibility in both light and dark modesChecked in mobileSafari, Edge, and FirefoxProps have proper autodocs and playground togglesAdded documentationChecked Code Sandbox works for any docs examplesChecked for breaking changes and labeled appropriatelyChecked for accessibility including keyboard-only and screenreader modes