Skip to content

Commit

Permalink
fix(slider-input): classnames overriding (#891)
Browse files Browse the repository at this point in the history
  • Loading branch information
reme3d2y committed Nov 22, 2021
1 parent 1f9fb97 commit d63d676
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
18 changes: 18 additions & 0 deletions packages/slider-input/src/Component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ describe('SliderInput', () => {

expect(container.getElementsByClassName(className).length).toBe(1);
});

it('should set `focusedClassName` class to slider', () => {
const className = 'test-class';
const { container, queryByRole } = render(<SliderInput focusedClassName={className} />);

const input = queryByRole('textbox');

if (input) input.focus();

expect(container.getElementsByClassName(className).length).toBe(1);
});

it('should set `fieldClassName` class to slider', () => {
const className = 'test-class';
const { container } = render(<SliderInput fieldClassName={className} />);

expect(container.getElementsByClassName(className).length).toBe(1);
});
});

describe('Attributes tests', () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/slider-input/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export const SliderInput = forwardRef<HTMLInputElement, SliderInputProps>(
inputClassName,
sliderClassName,
stepsClassName,
focusedClassName,
fieldClassName,
value = '',
min = 0,
max = 100,
Expand Down Expand Up @@ -179,8 +181,8 @@ export const SliderInput = forwardRef<HTMLInputElement, SliderInputProps>(
disabled={disabled}
readOnly={readOnly}
className={cn(inputClassName, styles.input)}
focusedClassName={styles.focused}
fieldClassName={styles.field}
focusedClassName={cn(focusedClassName, styles.focused)}
fieldClassName={cn(fieldClassName, styles.field)}
inputMode='numeric'
pattern='[0-9]*'
error={error}
Expand Down

0 comments on commit d63d676

Please sign in to comment.