Skip to content

Commit 0f04dd5

Browse files
committed
fix(input): align border styling with textarea and add input best practices
- Change default border from border-primary to border-border-primary for consistency with Textarea - Add autoComplete='off' to disable browser autocomplete - Add spellCheck='false' for text inputs to prevent red underlines - Add autoCapitalize='none' for email/URL inputs - Update tests to match new border styling expectations - Simplify variant logic while maintaining error precedence
1 parent 51c5e16 commit 0f04dd5

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/components/atoms/Input.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
3232
const baseClasses =
3333
'block w-full rounded-md border transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2';
3434

35-
// Fixed variant classes to match test expectations
35+
// Variant classes that match Textarea styling approach
3636
const variantClasses = {
3737
default:
3838
'border-border-primary bg-surface-primary text-text-primary placeholder-text-secondary focus:border-primary-500 focus:ring-primary-500',
@@ -50,19 +50,14 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
5050

5151
const disabledClasses = disabled
5252
? 'opacity-50 cursor-not-allowed bg-surface-disabled'
53-
: '';
53+
: 'hover:border-border-hover';
5454

5555
const readOnlyClasses = readOnly
5656
? 'bg-surface-secondary cursor-default'
5757
: '';
5858

59-
// Determine the effective variant
60-
const getEffectiveVariant = () => {
61-
if (error) return 'error';
62-
return variant;
63-
};
64-
65-
const effectiveVariant = getEffectiveVariant();
59+
// Determine the effective variant (error takes precedence)
60+
const effectiveVariant = error ? 'error' : variant;
6661

6762
const iconPadding = {
6863
left: leftIcon
@@ -132,6 +127,9 @@ const Input = forwardRef<HTMLInputElement, InputProps>(
132127
disabled={disabled}
133128
readOnly={readOnly}
134129
placeholder={placeholder}
130+
autoComplete="off"
131+
spellCheck={type === 'text' ? 'false' : undefined}
132+
autoCapitalize={type === 'email' || type === 'url' ? 'none' : undefined}
135133
aria-describedby={
136134
classNames(descriptionId, errorId).trim() || undefined
137135
}

src/components/atoms/__tests__/Input.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('Input', () => {
1010
render(<Input />);
1111
const input = screen.getByRole('textbox');
1212
expect(input).toBeInTheDocument();
13-
expect(input).toHaveClass('border-primary');
13+
expect(input).toHaveClass('border-border-primary');
1414
});
1515

1616
it('renders with label', () => {
@@ -100,7 +100,7 @@ describe('Input', () => {
100100
it('renders default variant correctly', () => {
101101
render(<Input variant='default' />);
102102
const input = screen.getByRole('textbox');
103-
expect(input).toHaveClass('border-primary');
103+
expect(input).toHaveClass('border-border-primary');
104104
});
105105

106106
it('renders error variant correctly', () => {

0 commit comments

Comments
 (0)