Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: wrapper also has oor cls #50

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
}
};

// ====================== Input =======================
const outOfRangeCls = isOutOfRange && `${prefixCls}-out-of-range`;

const getInputElement = () => {
// Fix https://fb.me/react-unknown-prop
const otherProps = omit(
Expand Down Expand Up @@ -186,7 +189,6 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
prefixCls,
{
[`${prefixCls}-disabled`]: disabled,
[`${prefixCls}-out-of-range`]: isOutOfRange,
},
classNames?.input,
)}
Expand Down Expand Up @@ -246,7 +248,7 @@ const Input = forwardRef<InputRef, InputProps>((props, ref) => {
<BaseInput
{...rest}
prefixCls={prefixCls}
className={className}
className={clsx(className, outOfRangeCls)}
inputElement={getInputElement()}
handleReset={handleReset}
value={formatValue}
Expand Down
29 changes: 29 additions & 0 deletions tests/count.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,33 @@ describe('Input.Count', () => {
expect(container.querySelector('input')?.value).toEqual('🔥');
expect(onCompositionEnd).toHaveBeenCalled();
});

describe('cls', () => {
it('raw', () => {
const { container } = render(
<Input
count={{
max: 3,
}}
defaultValue="bamboo"
/>,
);

expect(container.querySelector('.rc-input-out-of-range')).toBeTruthy();
});

it('wrapper', () => {
const { container } = render(
<Input
count={{
max: 3,
show: true,
}}
defaultValue="bamboo"
/>,
);

expect(container.querySelector('.rc-input-out-of-range')).toBeTruthy();
});
});
});
Loading