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

EuiRange and EuiDualRange fixes #1580

Merged
merged 17 commits into from
Feb 25, 2019
Merged

Conversation

cchaos
Copy link
Contributor

@cchaos cchaos commented Feb 20, 2019

Bug fixing

  • Gave the inputs a min-width in case of single digits. And remove shifting of inputs because they then don’t line up with other form rows
  • Custom tick values now properly account for minimum value
  • Fix styling of track color when not showing the range
  • Top level className now applied to the top level wrapper
  • Fixed prepend/append of value
  • Moved dual range handles to min and max positions if the values are empty
  • Dual range inputs account for both min and max for sizing

Added validations

The EuiRangeTrack and EuiRangeLevels now handle some errors of invalid steps/ticks.

Split up the docs page into more sections

screen shot 2019-02-20 at 14 33 08 pm

Todo:

  • Fix some state coloring of the dual range

@thompsongl I could use your help on the following

  • Fix starting click on dual range if the value is ['', '']

  • Fix dragging of handles on dual range where it doesn't seem to allow clicking on a different handle

  • Value tooltip gets narrow towards max value

screen shot 2019-02-20 at 14 15 30 pm

Checklist

  • This was checked in mobile
  • This was checked in IE11
  • This was checked in dark mode
  • Any props added have proper autodocs
  • Documentation examples were added
  • A changelog entry exists and is marked appropriately
  • This was checked for breaking changes and labeled appropriately
  • Jest tests were updated or added to match the most common scenarios
  • [ ] This was checked against keyboard-only and screenreader scenarios Crossing this one off because it's a bit out of scope for this PR. There is basic keyboard-only interactions though they could probably be enhanced.
  • [ ] This required updates to Framer X components

@thompsongl
Copy link
Contributor

thompsongl commented Feb 20, 2019

Things to know for:

  • Fix starting click on dual range if the value is ['', '']
  • Fix dragging of handles on dual range where it doesn't seem to allow clicking on a different handle ['', '']

The thumbs/handles are not actually clickable. They are non-interactive indicators of the range values. Clicks and drags simply return a number in the range (exactly how the single range slider works) and we map it to the most relevant thumb/handle.

When empty values were not valid, this was easier because we at least had points of reference. Now we have to try to infer which of the two values (min, max) the click is attempting to change. Chances are good we won't always be correct in this.

We can get better, but right now this is the approach (set both values in the area of the click):

// Scenerio in which we cannot reasonably infer intention via click location due to current invalid thumb positions.
// Reset both values in the proximity of the click.

@thompsongl
Copy link
Contributor

Rather than attempt to interpret ['', ''], what if in those scenarios we:

  1. don't render the thumbs
  2. show a "Click to enable" message
  3. on click, set the value to min and max

Users would then have a more reasonable experience with knowing disabled vs enabled, and what the intended interaction is

@cchaos
Copy link
Contributor Author

cchaos commented Feb 20, 2019

@thompsongl Can you check out the latest commit? Basically I released the lastThumbInteraction state on change, but that also negated the need for these checks

// Lower thumb nearing swap with upper thumb
if (
(newVal === upper || (newVal < upper && thumbsAreEquidistant))
&& this.state.lastThumbInteraction === 'lower'
) {
lower = newVal;
}
// Upper thumb nearing swap with lower thumb
else if (
(newVal === lower || (newVal > lower && thumbsAreEquidistant))
&& this.state.lastThumbInteraction === 'upper'
) {
upper = newVal;
}

I played around with it a bunch and I no longer get the issue I used to and it still seem to be working fine. But maybe they were trying to fix something I haven't run into.

I'll give the ['', ''] scenario some more thought, but generally I don't think we should force the user to initiate a component. We do know the bounds, so just show it to them. It's more a matter of showing the inputs as blank than the slider.

@cchaos
Copy link
Contributor Author

cchaos commented Feb 20, 2019

My latest commit also attempts to handle the invalid state by finding whether the new value is in the upper or lower half and moving the appropriate handle to the new value, while the other handle gets moved to the opposite bound.

@thompsongl
Copy link
Contributor

Latest commit fixes tooltip shrinkage

@thompsongl
Copy link
Contributor

thompsongl commented Feb 20, 2019

@thompsongl Can you check out the latest commit? Basically I released the lastThumbInteraction state on change, but that also negated the need for these checks

The one thing I see was re-introduced was a fix put in for the last comment here. Basically, during an "swap" there's a gap in values. If max is 50 and I overtake it with the min handle, min remains at 49, not 50. The gif in the original comment shows it best. (This is small potatoes, in my opinion, if we get better overall usability elsewhere)

My latest commit also attempts to handle the invalid state by finding whether the new value is in the upper or lower half and moving the appropriate handle to the new value, while the other handle gets moved to the opposite bound.

I think this is great. We have to make inferences somewhere, and this is the simplest place.

@cchaos
Copy link
Contributor Author

cchaos commented Feb 21, 2019

Ahh, I see. So playing with that more closely, it weirdly works correctly while dragging left (down) but skips 1 step when going right (up).

But I'll agree that it's such a small potato that the overall bug-less experience is worth that extra 1 step weirdness. Which I honestly don't think will be noticeable or common.

@thompsongl
Copy link
Contributor

@cchaos Correct about the left vs. right movement, hence the extra logic and tracking for which direction the handles were moving.
Again, I'm comfortable with the changes, especially given our statement regarding precision in the component docs.

cchaos and others added 9 commits February 21, 2019 11:58
- Give the inputs a min-width in case of single digits. And remove shifting of inputs because they then don’t line up with other form rows
- Custom tick values now properly account for minimum value
- Fix styling of track color when not showing the range
- Top level `className` should be applied to the top level wrapper
- Better error handling of invalid steps/ticks
- Also fixed prepend/append of value
Not worrying about what handle was clicked…
@cchaos cchaos force-pushed the dual-range-css-fixes branch from bde2431 to a1876a1 Compare February 21, 2019 16:58
@thompsongl
Copy link
Contributor

Keyboard behavior (arrows) doesn't work correctly with empty values.
I'll take on fixing this.

@cchaos cchaos changed the title [WIP] EuiRange and EuiDualRange fixes EuiRange and EuiDualRange fixes Feb 21, 2019
@cchaos
Copy link
Contributor Author

cchaos commented Feb 21, 2019

Thanks @thompsongl !!

Outside of that issue, this is no longer a WIP and ready for official review. 🙌

@cchaos
Copy link
Contributor Author

cchaos commented Feb 21, 2019

cc @nreese

@thompsongl
Copy link
Contributor

Keyboard support for ['', ''] added

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

Did a scan of functionality and a code scan of the Sass and docs. My comments are all on the docs side. Did not look too deep at the JS.

src-docs/src/views/range/range_example.js Outdated Show resolved Hide resolved
src-docs/src/views/range/range_example.js Outdated Show resolved Hide resolved
src-docs/src/views/range/range_example.js Outdated Show resolved Hide resolved
src-docs/src/views/range/range_example.js Outdated Show resolved Hide resolved
src/components/form/range/dual_range.js Outdated Show resolved Hide resolved
src/components/form/range/dual_range.js Outdated Show resolved Hide resolved
src/components/form/range/dual_range.js Show resolved Hide resolved
src/components/form/range/dual_range.js Show resolved Hide resolved
@cchaos cchaos requested a review from chandlerprall February 22, 2019 19:49
Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Lots of good stuff, changes LGTM!

@cchaos cchaos merged commit babf10c into elastic:master Feb 25, 2019
@cchaos cchaos deleted the dual-range-css-fixes branch February 25, 2019 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants