feat(Slider): add option to add Tooltip over thumb#6624
feat(Slider): add option to add Tooltip over thumb#6624tlabaj merged 1 commit intopatternfly:mainfrom
Conversation
| @@ -134,13 +135,22 @@ class ContinuousInput extends React.Component { | |||
| return ( | |||
| <> | |||
| <Text component={TextVariants.h3}>Slider value is: {this.state.value.toFixed(2)}</Text> | |||
There was a problem hiding this comment.
We should remove this line.
| value={this.state.value} | ||
| onChange={this.onChange} /> | ||
| <br /> | ||
| <Text component={TextVariants.h3}>Slider value is: {this.state.valueCustom.toFixed(2)}</Text> |
There was a problem hiding this comment.
As it is, the Slide value is: text in the example only has 2 values trailing the decimal, but the tooltip has many. I wonder if we should make the number of trailing values something the user can configure, and have it always default to 2? It'd make the aria label much more readable.
There was a problem hiding this comment.
Made it default to 2 decimals. Lets add the property for configuring once someone requests it if you 're fine with that.
There was a problem hiding this comment.
Could you also remove the trimming in the examples if it's no longer needed?
nicolethoen
left a comment
There was a problem hiding this comment.
Could you also add a unit test which basically verifies that a Tooltip gets rendered whenever thumbHasTooltip is true?
731fa84 to
637777f
Compare
Added |
637777f to
47ec8f7
Compare
47ec8f7 to
4c7be75
Compare
| return localValue.toString(); | ||
| // For continuous steps default to showing 2 decimals in tooltip | ||
| // Consider making it configurable via a property | ||
| return Number(localValue.toFixed(2)).toString(); |
There was a problem hiding this comment.
To piggy pack off of Matt's comment, I think we want to make this same update to the onChangeHandler function. Either that, or in the handleThumbMove function we should trim the continuous value on line 221 to use 2 trailing digits.
This is also broken on master, just checked. Let's fix it in a separate PR as it's unrelated. For your interest I just checked and it's ed777b2. which broke these. Added an issue for this bug: |
ec1f75e to
34e4351
Compare
| <Text component={TextVariants.h3}>Slider value is: {this.state.value.toFixed(2)}</Text> | ||
| <Slider value={this.state.value} onChange={this.onChange} /> | ||
| <Checkbox | ||
| id="thumb-has-tooltip" |
There was a problem hiding this comment.
I would add a style={{ marginBottom: 20 }} to the Checkbox.
34e4351 to
3f7e75a
Compare
gabipodolnikova
left a comment
There was a problem hiding this comment.
I also noticed that the Thumb value input example is broken, which it wasn't before. When I move it, I get: TypeError: W.toFixed is not a function Do you see it too?
3f7e75a to
e2ddb90
Compare
Yes, sorry. I fixed it. |
e2ddb90 to
4ec0bca
Compare
mcarrano
left a comment
There was a problem hiding this comment.
Tooltip option looks good, but some of the Discrete slider examples seem to be broken - specifically the first one and the first two Vale input examples. I cannot drag the slider.
@mcarrano This problem exists already upstream, see on the docs pge directly without my PR https://www.patternfly.org/v4/components/slider/ |
mcarrano
left a comment
There was a problem hiding this comment.
Fair enough @KKoukiou . In that case I will approve this PR, but @nicolethoen @tlabaj do you have any idea when or why these examples broke. We should try to clean them up for the next release. Do we need a new issue for this?
tlabaj
left a comment
There was a problem hiding this comment.
Looks great! One suggestion.
4ec0bca to
27932c6
Compare
tlabaj
left a comment
There was a problem hiding this comment.
Looks Good! Thank you!
Looks like you need to update the snapshots and we can merge.
27932c6 to
e9d2d2f
Compare

Fixes #5955