Skip to content

Commit

Permalink
feat: make tooltip non-interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
Arucard89 committed Jan 14, 2024
1 parent 10db4d6 commit 6142e26
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/components/Slider/SliderTooltip/SliderTooltip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $block: '.#{variables.$ns-new}slider-tooltip';
position: absolute;
top: -#{sliderVariables.$slider-tooltip-height};
transform: translateX(-50%);
// height: #{sliderVariables.$slider-tooltip-height};
cursor: default;

&__card {
position: relative;
Expand All @@ -17,7 +17,6 @@ $block: '.#{variables.$ns-new}slider-tooltip';
border-radius: 4px;
height: 24px;
padding: 4px 4px 2px;
// margin-bottom: auto;
background-color: #{sliderVariables.$slider-color};
font-size: var(--g-text-body-1-font-size);
color: #{sliderVariables.$handle-center-color};
Expand Down
28 changes: 21 additions & 7 deletions src/components/Slider/SliderTooltip/SliderTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,25 @@ type SliderTooltipProps = {
styleModifiers: Omit<StyleModifiers, 'withTooltip'>;
};

export const SliderTooltip = ({value, className, style, styleModifiers}: SliderTooltipProps) => (
<div className={b(styleModifiers, className)} style={style}>
<div className={b('card', styleModifiers)}>
{value}
<SliderTooltipPin className={b('pin')} />
export const SliderTooltip = ({value, className, style, styleModifiers}: SliderTooltipProps) => {
const preventAction = React.useCallback((e: React.SyntheticEvent) => {
//make tooltip non-interactive
e.preventDefault();
e.stopPropagation();
}, []);
return (
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
<div
className={b(styleModifiers, className)}
style={style}
onClick={preventAction}
onMouseDown={preventAction}
onTouchStart={preventAction}
>
<div className={b('card', styleModifiers)}>
{value}
<SliderTooltipPin className={b('pin')} />
</div>
</div>
</div>
);
);
};

0 comments on commit 6142e26

Please sign in to comment.