-
Notifications
You must be signed in to change notification settings - Fork 842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed super date picker crash #5263
fixed super date picker crash #5263
Conversation
Preview documentation changes for this PR: https://eui.elastic.co/pr_5263/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to push an i18ntoken file cleanup commit, but otherwise this LGTM
Really appreciate the help, @JordanSh!
@@ -58,6 +58,10 @@ export function formatTimeString( | |||
} | |||
|
|||
const tryParse = dateMath.parse(timeString, { roundUp: roundUp }); | |||
if (!moment(tryParse).isValid()) { | |||
return 'Invalid Date'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see this use i18n, but none of the other values from this function use it and it's unclear how we'd adjust the output.
I'll open a separate issue to explore (#5266); this doesn't need to be a blocker for this PR.
Preview documentation changes for this PR: https://eui.elastic.co/pr_5263/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again, @JordanSh!
thanks for the quick review @thompsongl :) |
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