Skip to content

Added forceVisible parameter to tipProps.#383

Merged
yesmeck merged 3 commits intoreact-component:masterfrom
ioziian:master
Jan 12, 2018
Merged

Added forceVisible parameter to tipProps.#383
yesmeck merged 3 commits intoreact-component:masterfrom
ioziian:master

Conversation

@ioziian
Copy link

@ioziian ioziian commented Dec 26, 2017

If need always to show toolTip value.

I want to show toolTip always. But I can't change this state. It works only on hover.
https://github.com/react-component/slider/blob/master/src/createSliderWithTooltip.jsx#L61
I added this changes because custom toolTip doesn't work.
#377

If need always to show toolTip value.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 72.941% when pulling 99038c8 on oziian:master into db32618 on react-component:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 72.941% when pulling d14fb7d on oziian:master into db32618 on react-component:master.

@tmikoss
Copy link

tmikoss commented Dec 29, 2017

Would love this, or really any other way of forcing tooltips visible at all times.

@yesmeck
Copy link
Member

yesmeck commented Jan 4, 2018

I think we can just call it visible?

@yesmeck yesmeck requested a review from benjycui January 4, 2018 10:48
@ioziian
Copy link
Author

ioziian commented Jan 11, 2018

Renamed to visible.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 72.941% when pulling 21d9dce on oziian:master into db32618 on react-component:master.

@yesmeck yesmeck merged commit b90084c into react-component:master Jan 12, 2018
@yesmeck
Copy link
Member

yesmeck commented Jan 12, 2018

Thanks!

@mradzwilla
Copy link

Can someone provide an example of how to implement this feature?

@ioziian
Copy link
Author

ioziian commented Feb 17, 2018

@mradzwilla You need just add visible={true}.
But I didn't find my code in the npm repository. The repository published a month ago, and my code merged at the same time.
I think we will need to wait until @yesmeck publish code into npm again.

import React from 'react';
import PropTypes from 'prop-types';
import Slider from 'rc-slider';

const createSliderWithTooltip = Slider.createSliderWithTooltip;
const Range = createSliderWithTooltip(Slider.Range);

export class RangePrice extends React.Component {
	constructor (props) {
		super(props);
		this.state = {
			min: props.min,
			max: props.max
		};
		this.onChange = this.onChange.bind(this);
	}

	onChange (value) {
		this.props.onChange({min: value[0], max: value[1]})
	};

	componentWillReceiveProps(nextProps) {
		if (nextProps.max !== this.props.max) {
			this.setState({max: nextProps.max});
		}
		if (nextProps.min !== this.props.min) {
			this.setState({min: nextProps.min});
		}
	}

	render() {
		let defaultValue = [this.state.min, this.state.max];
		return(
			<div className="range-price">
				<Range min={this.state.min}
				       max={this.state.max}
				       defaultValue={defaultValue}
				       onChange={this.onChange}
				       visible={true}
				       tipFormatter={value => value} />
			</div>
		)
	}
}

RangePrice.propTypes = {
	min: PropTypes.number,
	max: PropTypes.number,
	onChange: PropTypes.func,
};

RangePrice.defaultProps = {
	min: 0,
	max: 100,
	onChange: () => {},
}; 

@lunatik-210
Copy link

I suppose it is in tipsProps like that:

tipProps={{visible: true}}

Otherwise, it's not showing up..

But there's a consequence of that, tooltips are not updating with a scroll, and will show randomly on the page until you will mouse focus on the slider itself. Are there any ways to overcome it? Or should i open a bug?

@yesmeck
Copy link
Member

yesmeck commented Mar 14, 2018

@lunatik-210 Please file a new issue and try to reproduce it on https://codesandebox.io

@computerjazz
Copy link

I'm seeing the buggy behavior in my app as well.
rc-slider-bu

However, when I created an example it works as expected:
https://codesandbox.io/s/j2x418y2yw

@okrookrps
Copy link

I'm seeing the buggy behavior in my app as well.
rc-slider-bu

However, when I created an example it works as expected:
https://codesandbox.io/s/j2x418y2yw

Here is the reproducible example
https://codesandbox.io/s/yv39p3qmx

wbrgss added a commit to plotly/dash-core-components that referenced this pull request Jun 3, 2019
This is so we can use the `visible` prop
in `tipProps`, introduced in `rc-slider` 8.6.1
(undocumented in the `rc-slider` repo's HISTORY.md)

See react-component/slider#383
wbrgss added a commit to plotly/dash-core-components that referenced this pull request Jun 8, 2019
This is so we can use the `visible` prop
in `tipProps`, introduced in `rc-slider` 8.6.1
(undocumented in the `rc-slider` repo's HISTORY.md)

See react-component/slider#383
wbrgss added a commit to plotly/dash-core-components that referenced this pull request Jun 12, 2019
This is so we can use the `visible` prop
in `tipProps`, introduced in `rc-slider` 8.6.1
(undocumented in the `rc-slider` repo's HISTORY.md)

See react-component/slider#383
wbrgss added a commit to plotly/dash-core-components that referenced this pull request Jun 12, 2019
* Bump rc-slider minor version

This is so we can use the `visible` prop
in `tipProps`, introduced in `rc-slider` 8.6.1
(undocumented in the `rc-slider` repo's HISTORY.md)

See react-component/slider#383

* Add tooltip (basic `tipProps` alias) to Slider and RangeSlider

Adds support for hoverable and persistent (always visible) tooltips

* Remove test css class + undo loading_state propTypes reshuffle

* Add propTypes variations template

* Put `createSliderWithTooltip` in constructor

* Change 'visible' tooltip propType to bool

* Fix Slider.react.js 🍝 from RangeSlider

* Slider tooltip propTypes: `oneOfType[]` -> single `exact`

* Move Slider instantiation from constructor to render method

* Spacing

* Add changelog entry for Slider/RangeSlider tooltips

* Fix markdown syntax + parens

* Prettier (comment + ternary formatting)

* `visible` -> `always_visible`; `position` -> `placement`

* Add DashSlider conditional in componentWillReceiveProps
HammadTheOne pushed a commit to HammadTheOne/dash that referenced this pull request May 28, 2021
* Bump rc-slider minor version

This is so we can use the `visible` prop
in `tipProps`, introduced in `rc-slider` 8.6.1
(undocumented in the `rc-slider` repo's HISTORY.md)

See react-component/slider#383

* Add tooltip (basic `tipProps` alias) to Slider and RangeSlider

Adds support for hoverable and persistent (always visible) tooltips

* Remove test css class + undo loading_state propTypes reshuffle

* Add propTypes variations template

* Put `createSliderWithTooltip` in constructor

* Change 'visible' tooltip propType to bool

* Fix Slider.react.js 🍝 from RangeSlider

* Slider tooltip propTypes: `oneOfType[]` -> single `exact`

* Move Slider instantiation from constructor to render method

* Spacing

* Add changelog entry for Slider/RangeSlider tooltips

* Fix markdown syntax + parens

* Prettier (comment + ternary formatting)

* `visible` -> `always_visible`; `position` -> `placement`

* Add DashSlider conditional in componentWillReceiveProps
AnnMarieW pushed a commit to AnnMarieW/dash that referenced this pull request Jan 6, 2022
* Bump rc-slider minor version

This is so we can use the `visible` prop
in `tipProps`, introduced in `rc-slider` 8.6.1
(undocumented in the `rc-slider` repo's HISTORY.md)

See react-component/slider#383

* Add tooltip (basic `tipProps` alias) to Slider and RangeSlider

Adds support for hoverable and persistent (always visible) tooltips

* Remove test css class + undo loading_state propTypes reshuffle

* Add propTypes variations template

* Put `createSliderWithTooltip` in constructor

* Change 'visible' tooltip propType to bool

* Fix Slider.react.js 🍝 from RangeSlider

* Slider tooltip propTypes: `oneOfType[]` -> single `exact`

* Move Slider instantiation from constructor to render method

* Spacing

* Add changelog entry for Slider/RangeSlider tooltips

* Fix markdown syntax + parens

* Prettier (comment + ternary formatting)

* `visible` -> `always_visible`; `position` -> `placement`

* Add DashSlider conditional in componentWillReceiveProps
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.

8 participants