Added forceVisible parameter to tipProps.#383
Added forceVisible parameter to tipProps.#383yesmeck merged 3 commits intoreact-component:masterfrom
Conversation
If need always to show toolTip value.
|
Would love this, or really any other way of forcing tooltips visible at all times. |
|
I think we can just call it |
|
Renamed to |
|
Thanks! |
|
Can someone provide an example of how to implement this feature? |
|
@mradzwilla You need just add 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: () => {},
}; |
|
I suppose it is in tipsProps like that:
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? |
|
@lunatik-210 Please file a new issue and try to reproduce it on https://codesandebox.io |
|
I'm seeing the buggy behavior in my app as well. However, when I created an example it works as expected: |
Here is the reproducible example |
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
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
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
* 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
* 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
* 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


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