Skip to content

Commit

Permalink
fix(slider): disabled focus and styles (#17675)
Browse files Browse the repository at this point in the history
* fix(slider): disabled focus and styles

* fix(slider): disabled active styles
  • Loading branch information
ariellalgilmore authored Oct 14, 2024
1 parent 0c39d8f commit 9a4c29b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/react/src/components/Slider/Slider-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ describe('Slider', () => {

await click(lowerThumb);
await keyboard('{ArrowRight}');
expect(lowerThumb).toHaveFocus();
expect(lowerThumb).not.toHaveFocus();
expect(lowerInput).toHaveValue(initialValueLower);
expect(lowerThumb).toHaveAttribute(
'aria-valuenow',
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Slider/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ class Slider extends PureComponent<SliderProps> {
className={lowerThumbClasses}
role="slider"
id={twoHandles ? undefined : id}
tabIndex={!readOnly ? 0 : -1}
tabIndex={readOnly || disabled ? undefined : 0}
aria-valuetext={`${formatLabel(value, '')}`}
aria-valuemax={twoHandles ? valueUpper : max}
aria-valuemin={min}
Expand Down Expand Up @@ -1554,7 +1554,7 @@ class Slider extends PureComponent<SliderProps> {
<div
className={upperThumbClasses}
role="slider"
tabIndex={!readOnly ? 0 : -1}
tabIndex={readOnly || disabled ? undefined : 0}
aria-valuemax={max}
aria-valuemin={value}
aria-valuenow={valueUpper}
Expand Down
16 changes: 16 additions & 0 deletions packages/styles/scss/components/slider/_slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,22 @@
}
}

.#{$prefix}--slider--disabled .#{$prefix}--slider__thumb--lower,
.#{$prefix}--slider--disabled .#{$prefix}--slider__thumb--upper {
background-color: transparent;

&:active,
&:hover,
&:focus {
background-color: transparent;
transform: none;
}

.#{$prefix}--slider__thumb-icon {
fill: $border-disabled;
}
}

.#{$prefix}--slider--disabled .#{$prefix}--slider__track,
.#{$prefix}--slider--disabled .#{$prefix}--slider__filled-track,
.#{$prefix}--slider--disabled
Expand Down

0 comments on commit 9a4c29b

Please sign in to comment.