Repository navigation
Conversation
The tooltip was a child of the thumb. Radix wraps each thumb in a transformed span, and the slider root had z-index: 0, so the tooltip could not be drawn above a slider placed after it. Render the tooltip as a sibling of the thumb, in an anchor that copies the thumb's box and position, and stop making the root a stacking context. Fixes plotly#3632
|
T4rk1n
left a comment
There was a problem hiding this comment.
Fix is right. Dropping the root z-index and pulling the tooltip out of Radix's transformed span is the only way to get it above the next slider, and I checked the sibling selectors against Radix 1.6.1 (wrapper span, then the input only in a form). slsl021 will catch it if a Radix bump changes that structure. Tests are good. Nothing here blocks merge.
The one thing I'd like addressed is the hardcoded thumb size, since the anchor now guesses the thumb's box where the tooltip used to follow the real one. Details inline. Leaving the disabled case for a follow-up is fine, can you open an issue for it so it doesn't get lost?
| }; | ||
|
|
||
| // Same box Radix measures on the thumb: 16px plus a 2px border on each side | ||
| const THUMB_OUTER_SIZE = 20; |
There was a problem hiding this comment.
Radix measures the real thumb and uses that size for the offset. This uses a fixed 20, and sliders.css:141 fixes the anchor box at 16px plus border too. If an app makes the thumb bigger (.dash-slider-thumb { width: 24px; height: 24px }), the tooltip is no longer centered on the thumb and drifts more near min and max. Before, the tooltip followed whatever the thumb was. Can you drive both the thumb and the anchor from one CSS variable? The offset can live in CSS as well: Radix's formula is halfSize * (1 - percent / 50), so JS only needs to set the percentage.
|
|
||
| // The inset Radix gives the span around a thumb, for content that has to | ||
| // follow a thumb without being inside it | ||
| export const getThumbInset = ( |
There was a problem hiding this comment.
This repeats getRadixThumbPosition a few lines up, plus direction and size. Can you extend that one with size and direction params instead of adding a second copy?






Fixes #3632. Targets
dev.With two sliders stacked, the first one's tooltip was painted under the second slider.
The tooltip's
z-index: 1000had no effect outside its own slider, for two reasons:.dash-slider-roothadz-index: 0, so each slider was its own stacking context and the later one always won.I first tried lifting that Radix span with CSS. It fixed the case in the issue, but the next slider's thumb still showed through the tooltip when the two lined up, so I moved the tooltip out of the thumb instead.
Changes
.dash-slider-tooltip-anchordiv that copies the thumb's box and position. Tooltip placement is unchanged (checked to the pixel for horizontal, reversed, range and vertical sliders).z-index. The anchor hasz-index: 1, or2while its thumb is hovered or focused. Both stay well below the dropdown and date picker popups (500).aria-hidden, to match the old behaviour where the tooltip sat insiderole="slider".One visible side effect: the tooltip no longer scales up with the thumb on hover.
Not covered
A disabled slider still has the bug, because
opacityon its root is a stacking context as well. Fixing it changes how every disabled slider is blended, so I left it for a follow-up. Happy to add it here if you prefer.Testing
test_slsl021_tooltip_above_next_sliderchecks that nothing is painted over the tooltip: next slider's thumb right under it, range slider, hover, keyboard focus, and a slider inside a form.test_slsl022_tooltip_follows_thumbchecks that the anchor matches the thumb's rectangle in every orientation.Both fail on
devand pass with this change. The rest oftests/integration/sliderspasses locally.Contributor Checklist
dev(fix or chore) ornext(feature, new API, breaking change), see Which branch to targetoptionals
CHANGELOG.md