Skip to content

Commit

Permalink
fix(Slider): pass correct data attribute to slider thumb component
Browse files Browse the repository at this point in the history
  • Loading branch information
sjschlapbach committed Jan 30, 2025
1 parent debbc5a commit 2575c1b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions packages/design-system/src/Slider.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export const Compact = () => {
min={-5}
max={5}
step={0.3}
data={{ cy: 'slider-cy', test: 'slider-test' }}
dataThumb={{ cy: 'slider-thumb-cy', test: 'slider-thumb-test' }}
/>
<div>Slider value: {value}</div>
</div>
Expand Down
15 changes: 8 additions & 7 deletions packages/design-system/src/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import { twMerge } from 'tailwind-merge'

interface SliderProps {
id?: string
data?: {
cy?: string
test?: string
}
value?: number
handleChange: (newValue: number) => void
defaultValue?: number
Expand All @@ -29,6 +25,10 @@ interface SliderProps {
thumb?: string
lock?: string
}
data?: {
cy?: string
test?: string
}
dataThumb?: {
cy?: string
test?: string
Expand Down Expand Up @@ -73,7 +73,6 @@ export interface SliderWithIconsProps extends SliderProps {
*/
export function Slider({
id,
data,
value,
labels,
handleChange,
Expand All @@ -87,6 +86,8 @@ export function Slider({
rangeColorMap,
borderColorMap,
className,
data,
dataThumb,
}: SliderWithLabelProps | SliderWithIconsProps): React.ReactElement {
const steps =
min < 0 && max > 0
Expand Down Expand Up @@ -165,8 +166,8 @@ export function Slider({
: borderColorMap[String(value)],
className?.thumb
)}
data-cy={data?.cy}
data-test={data?.test}
data-cy={dataThumb?.cy}
data-test={dataThumb?.test}
>
{disabled && (
<FontAwesomeIcon
Expand Down

0 comments on commit 2575c1b

Please sign in to comment.