Skip to content

feat(Slider): add option to add Tooltip over thumb#6624

Merged
tlabaj merged 1 commit intopatternfly:mainfrom
KKoukiou:slider-tooltip
Jan 6, 2022
Merged

feat(Slider): add option to add Tooltip over thumb#6624
tlabaj merged 1 commit intopatternfly:mainfrom
KKoukiou:slider-tooltip

Conversation

@KKoukiou
Copy link
Copy Markdown
Collaborator

Fixes #5955

@patternfly-build
Copy link
Copy Markdown
Collaborator

patternfly-build commented Nov 18, 2021

@@ -134,13 +135,22 @@ class ContinuousInput extends React.Component {
return (
<>
<Text component={TextVariants.h3}>Slider value is: {this.state.value.toFixed(2)}</Text>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should remove this line.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed.

value={this.state.value}
onChange={this.onChange} />
<br />
<Text component={TextVariants.h3}>Slider value is: {this.state.valueCustom.toFixed(2)}</Text>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Made it default to 2 decimals. Lets add the property for configuring once someone requests it if you 're fine with that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you also remove the trimming in the examples if it's no longer needed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Contributor

@nicolethoen nicolethoen left a comment

Choose a reason for hiding this comment

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

Could you also add a unit test which basically verifies that a Tooltip gets rendered whenever thumbHasTooltip is true?

@KKoukiou
Copy link
Copy Markdown
Collaborator Author

Could you also add a unit test which basically verifies that a Tooltip gets rendered whenever thumbHasTooltip is true?

Added

Copy link
Copy Markdown
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

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

This looks good, although while the tooltip in the example is constrained to 2 decimal places, the value displayed is not. Shouldn't these match? Here's what I'm seeing.

Screen Shot 2021-11-22 at 10 34 21 AM

Also, it seems like the Value input examples are broken. Maybe unrelated to your changes, but can you check these?

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();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@KKoukiou
Copy link
Copy Markdown
Collaborator Author

KKoukiou commented Nov 24, 2021

This looks good, although while the tooltip in the example is constrained to 2 decimal places, the value displayed is not. Shouldn't these match? Here's what I'm seeing.

Screen Shot 2021-11-22 at 10 34 21 AM

Also, it seems like the Value input examples are broken. Maybe unrelated to your changes, but can you check these?

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:
#6644

@KKoukiou KKoukiou force-pushed the slider-tooltip branch 2 times, most recently from ec1f75e to 34e4351 Compare November 24, 2021 11:59
<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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would add a style={{ marginBottom: 20 }} to the Checkbox.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added.

Copy link
Copy Markdown
Contributor

@gabipodolnikova gabipodolnikova left a comment

Choose a reason for hiding this comment

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

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?

@KKoukiou
Copy link
Copy Markdown
Collaborator Author

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?

Yes, sorry. I fixed it.

@nicolethoen nicolethoen requested a review from mcarrano November 30, 2021 13:46
Copy link
Copy Markdown
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

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

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.

@KKoukiou
Copy link
Copy Markdown
Collaborator Author

KKoukiou commented Nov 30, 2021

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/

Copy link
Copy Markdown
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

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

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?

@KKoukiou
Copy link
Copy Markdown
Collaborator Author

KKoukiou commented Dec 1, 2021

@mcarrano I created an issue last week about it: #6644

Copy link
Copy Markdown
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

Looks great! One suggestion.

Comment thread packages/react-core/src/components/Slider/Slider.tsx Outdated
Copy link
Copy Markdown
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

Looks Good! Thank you!
Looks like you need to update the snapshots and we can merge.

@tlabaj tlabaj merged commit cbe60e6 into patternfly:main Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slider: can we provide a tooltip for the thumb like PF3 did?

6 participants