fixed super date picker crash#5263
Merged
JordanSh merged 4 commits intoelastic:masterfrom Oct 13, 2021
Merged
Conversation
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5263/ |
thompsongl
reviewed
Oct 13, 2021
Contributor
thompsongl
left a comment
There was a problem hiding this comment.
I'm going to push an i18ntoken file cleanup commit, but otherwise this LGTM
Really appreciate the help, @JordanSh!
|
|
||
| const tryParse = dateMath.parse(timeString, { roundUp: roundUp }); | ||
| if (!moment(tryParse).isValid()) { | ||
| return 'Invalid Date'; |
Contributor
There was a problem hiding this comment.
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/ |
thompsongl
approved these changes
Oct 13, 2021
Contributor
thompsongl
left a comment
There was a problem hiding this comment.
Thanks again, @JordanSh!
Contributor
Author
|
thanks for the quick review @thompsongl :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
SuperDatePickerwas crashing due totoAbsoluteStringcallingtoISOStringon 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
toAbsoluteStringis"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 Datelabel to thepretty_durationoutput in that case.note: this change will prevent
super_date_pickerfrom crashing but a piece of code in Kibana repeats the same mistake by callingtoISOStringon 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