Skip to content

Commit

Permalink
fix: Fixed a problem with Tooltip display in Slider when tipFormatter… (
Browse files Browse the repository at this point in the history
#2374)

* fix: Fixed a problem with Tooltip display in Slider when tipFormatter is null and the handler is focused through Tab

* fix: [Slider] when tipFormatter is null or tooltipVisible is false, do not show tooltip when dot active
  • Loading branch information
YyumeiZhang authored Aug 9, 2024
1 parent ef8a3a5 commit 55bd845
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/semi-foundation/slider/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,16 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
}
}

_noTooltip = () => {
const { tipFormatter, tooltipVisible } = this.getProps();
return tipFormatter === null || tooltipVisible === false;
}

onFocus = (e: any, handler: 'min'| 'max') => {
const noTooltip = this._noTooltip();
if (noTooltip) {
return;
}
handlePrevent(e);
const { target } = e;
try {
Expand All @@ -703,6 +712,10 @@ export default class SliderFoundation extends BaseFoundation<SliderAdapter> {
}

onBlur = (e: any, handler: 'min'| 'max') => {
const noTooltip = this._noTooltip();
if (noTooltip) {
return;
}
const { firstDotFocusVisible, secondDotFocusVisible } = this.getStates();
if (handler === 'min') {
firstDotFocusVisible && this._adapter.setStateVal('firstDotFocusVisible', false);
Expand Down
9 changes: 9 additions & 0 deletions packages/semi-ui/slider/_story/slider.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ export const HorizontalSlider = () => (
}}
></Slider>
</div>
<div style={divStyle}>
<div>tooltipVisible=false,不显示tooltip</div>
<Slider
tooltipVisible={false}
onChange={value => {
console.log('value改变了' + value);
}}
></Slider>
</div>
<div style={divStyle}>
<div>step=10</div>
<Slider
Expand Down

0 comments on commit 55bd845

Please sign in to comment.