-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Input controls vis] replace react-input-range with EuiDualRange #31119
Conversation
Pinging @elastic/kibana-app |
💔 Build Failed |
@nreese Is this ready for review? It doesn't seem to be rendering correctly: |
💔 Build Failed |
💔 Build Failed |
Yes, the PR is ready for review. The flight dashboard provided a lot of decimal places which broke the formatting. I have fixed those problems now. |
💔 Build Failed |
Unfortunately, it looks like we have more work to do on the the EUI dual slider cc @thompsongl |
@cchaos Are you going to open an EUI issue or do you want me to open an issue? |
I can make an issue |
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.
Also, thank you for fixing the validation error that expected super precise values to be selected.
showInput | ||
showRange | ||
showTicks | ||
ticks={ticks} |
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.
So the main issue that was happening was with the ticks. I see that you're only adding the min and max as ticks, which isn't necessary since we have the showLabels
prop which automatically appends the min and max values passed. Like so:
However, I was going to suggest auto-filling the inputs with the min/max numbers so the range wasn't in a weird state like the above, but basically looked like it has the whole range selected. Therefore, if we do that, then we don't need the showLabels
because the inputs will already show those numbers and it's quite easy to reset to the whole range with the reset button:
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've do have to put in a fix for the input sizing and I saw a few other bugs, but this should allow you to continue with the PR.
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 see that you're only adding the min and max as ticks, which isn't necessary since we have the
showLabels
prop which automatically appends the min and max values passed
The problem with showLabels
is that it displays the labels inline with the slider. For input controls, horizontal space is at a premium so I wanted the labels below the slider to save horizontal space. I also really like the ability to select a tick to set the value
However, I was going to suggest auto-filling the inputs with the min/max numbers so the range wasn't in a weird state like the above
You can not pre set the values to the entire range because then that suggests that there is a range filter already applied. The default state is that the slider has no values. Then you can use the slider to specify a range.
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.
Then we need to somehow disconnect empty values from the look of the range because the range looks broken.
Also the ticks are broken right now because custom ticks don't correctly take into account the min value, it's always based on 0
being the min. I'm looking into it now.
static getDerivedStateFromProps(nextProps, prevState) { | ||
const nextValue = nextProps.control.hasValue() | ||
? [nextProps.control.value.min, nextProps.control.value.max] | ||
: ['', '']; |
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 wouldn't pass blank values if the user hasn't changed them, I would set them to the min/max values available.
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.
The empty state is not value. Setting to min and max makes the user assume there is a filter applied which is not the case
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.
Doesn't the absence of values mean that the full range is in play, though?
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.
Doesn't the absence of values mean that the full range is in play, though?
No, the absence of values means that there is nothing set. Logically that does mean that the entire range is in play but setting a range and having the range be unset are 2 important UI states.
- When the range is unset, there is not range filtering the results. The UI needs to be empty to show the user that no filtering is being applied.
- When a range is set, there is a range filtering the results. The UI needs to show the user the range so they can visually see how their data is being filtered.
The min/max range will change depending on user selected time, active filters, and query. Showing the entire range as selected is misleading when no range filter is getting applied.
isValid = false; | ||
errorMessage = formatMessage({ | ||
id: 'common.ui.dualRangeControl.mustSetBothErrorMessage', | ||
defaultMessage: 'both lower and upper value must be set' |
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.
Don't forget to always use sentence case
defaultMessage: 'both lower and upper value must be set' | |
defaultMessage: 'Both lower and upper values must be set' |
isValid = false; | ||
errorMessage = formatMessage({ | ||
id: 'common.ui.dualRangeControl.outsideOfRangeErrorMessage', | ||
defaultMessage: 'must be between {min} and {max}' |
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.
defaultMessage: 'must be between {min} and {max}' | |
defaultMessage: 'Values must be on or between {min} and {max}' |
isValid = false; | ||
errorMessage = formatMessage({ | ||
id: 'common.ui.dualRangeControl.upperValidErrorMessage', | ||
defaultMessage: 'upper must be greater or equal to lower' |
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.
defaultMessage: 'upper must be greater or equal to lower' | |
defaultMessage: 'Upper value must be greater or equal to lower value' |
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.
Overall LGTM! Added a few minor notes.
Only thing I'm seeing that feels amiss is a prop type warning on one of the sample data dashboards that includes the range slider:
Warning: Failed prop type: The prop `value` is marked as required in `EuiRangeInput`, but its value is `null`.
Appears on initial page load when viewing the dashboard that comes with the web logs sample data, but I don't see it when creating a slider from within the visualize app.
The custom tick min value looks to be a bug, but I'm not exactly sure what to do about not passing values. In the 1-4 range case, aren't |
@thompsongl I've got a branch going that will fix that bug (it just doesn't take the min value into consideration). |
@cchaos If it's valid for a range to be set but to also not participate in that range (empty string values), do we need to have some other visual state? |
@nreese The EuiRange/EuiDualRange fixes went out with EUI 7.3.0. You should be able to update and get those fixes now. |
waiting on #32009 to update Kibana's EUI version |
@lukeelmers @cchaos This PR is ready for a final review. |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
…s any text, update snapshots
💔 Build Failed |
💚 Build Succeeded |
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.
Code all LGTM, no concerns there.
In re-testing locally, there are just two things I'm still noticing... specifically looking at the Web Traffic dashboard that comes with the sample data:
- Might be more of an EUI question, but sliding the input control is still somewhat choppy -- wondering if maybe we need to debounce the
onChange
even more? Hard to tell if it is a debounce issue, or some other issue with the click events to actually drag the slider, but you can't just click and drag smoothly anymore like you could in the old implementation. - Still getting a propType warning. This occurs when I apply a filter via the range slider, then click in each of the text boxes and hit delete/backspace to reset the slider. Interestingly, I can't reproduce this one consistently. Like 25% of the time.
Warning: Failed prop type: The prop `value` is marked as required in `EuiRangeInput`, but its value is `null
Appears that |
Thanks for pointing this out. I have corrected the problem and now min or max of null will set the value to |
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.
Tested again and the choppiness I was experiencing before seems to be gone. Unclear if it had something to do with the recent updates, or if my browser was just laggy at the time of testing.
Either way, LGTM! I'm consistently getting smooth dragging now.
💚 Build Succeeded |
Replace react-input-range with EuiDualRange for Input control range slider
PR creates
ValidatedDualRange
which will also be used in the Maps application