Skip to content
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

Merged
merged 17 commits into from
Mar 11, 2019

Conversation

nreese
Copy link
Contributor

@nreese nreese commented Feb 14, 2019

Replace react-input-range with EuiDualRange for Input control range slider

PR creates ValidatedDualRange which will also be used in the Maps application

screen shot 2019-02-14 at 7 08 19 am

@nreese nreese added Feature:Input Control Input controls visualization Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 v7.2.0 labels Feb 14, 2019
@nreese nreese requested a review from a team as a code owner February 14, 2019 14:07
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app

@nreese nreese added the chore label Feb 14, 2019
@nreese nreese requested a review from lukeelmers February 14, 2019 14:36
@elasticmachine
Copy link
Contributor

💔 Build Failed

@cchaos
Copy link
Contributor

cchaos commented Feb 14, 2019

@nreese Is this ready for review? It doesn't seem to be rendering correctly:
image

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@nreese
Copy link
Contributor Author

nreese commented Feb 14, 2019

Is this ready for review? It doesn't seem to be rendering correctly

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.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@cchaos
Copy link
Contributor

cchaos commented Feb 15, 2019

Unfortunately, it looks like we have more work to do on the the EUI dual slider

cc @thompsongl

@nreese
Copy link
Contributor Author

nreese commented Feb 15, 2019

Unfortunately, it looks like we have more work to do on the the EUI dual slider

@cchaos Are you going to open an EUI issue or do you want me to open an issue?

@cchaos
Copy link
Contributor

cchaos commented Feb 15, 2019

I can make an issue

Copy link
Contributor

@cchaos cchaos left a 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}
Copy link
Contributor

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:

screen shot 2019-02-15 at 16 29 41 pm

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:

screen shot 2019-02-15 at 16 33 13 pm

Copy link
Contributor

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.

Copy link
Contributor Author

@nreese nreese Feb 15, 2019

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.

Copy link
Contributor

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]
: ['', ''];
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

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.

  1. 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.
  2. 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'
Copy link
Contributor

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

Suggested change
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}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
defaultMessage: 'upper must be greater or equal to lower'
defaultMessage: 'Upper value must be greater or equal to lower value'

Copy link
Member

@lukeelmers lukeelmers left a 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.

@thompsongl
Copy link
Contributor

thompsongl commented Feb 19, 2019

Unfortunately, it looks like we have more work to do on the the EUI dual slider

cc @thompsongl

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 min: 1 & max: 4 still used as filters for the resulting data? If not, how is that range determined?

@cchaos
Copy link
Contributor

cchaos commented Feb 19, 2019

@thompsongl I've got a branch going that will fix that bug (it just doesn't take the min value into consideration).

@thompsongl
Copy link
Contributor

@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?
As a user, I see that the values must be between 1 and 4, but also that it's acceptable for the values to not be between 1 and 4.
(We can certainly move this to a EUI issue if that makes more sense)

@cchaos
Copy link
Contributor

cchaos commented Feb 26, 2019

@nreese The EuiRange/EuiDualRange fixes went out with EUI 7.3.0. You should be able to update and get those fixes now.

@nreese
Copy link
Contributor Author

nreese commented Feb 26, 2019

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

@nreese
Copy link
Contributor Author

nreese commented Mar 7, 2019

@lukeelmers @cchaos This PR is ready for a final review.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@lukeelmers lukeelmers left a 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:

  1. 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.
  2. 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

Here's a screencap showing both behaviors:
Kapture 2019-03-08 at 18 52 34

@thompsongl
Copy link
Contributor

  1. Still getting a propType warning.

Appears that null sometimes gets passed as one of the initial value array values.
The validation at https://github.com/elastic/kibana/pull/31119/files#diff-a2c37d103458f78d5263f7a848c39924R50 (control.hasValue()) guards against both values being null, but not min or max individually

@nreese
Copy link
Contributor Author

nreese commented Mar 11, 2019

(control.hasValue()) guards against both values being null, but not min or max individually

Thanks for pointing this out. I have corrected the problem and now min or max of null will set the value to ''.

Copy link
Member

@lukeelmers lukeelmers left a 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.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Feature:Input Control Input controls visualization release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.2.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants