Skip to content
Open
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
8 changes: 8 additions & 0 deletions website/src/components/SearchPage/fields/TextField.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ describe('TextField', () => {
expect(handleChange).toHaveBeenCalled();
});

it('applies transparent background classes to label in placeholder state', () => {
render(<TextField label='Test Field' />);

const label = screen.getByText('Test Field');
expect(label).toHaveClass('peer-placeholder-shown:!bg-transparent');
Comment on lines +34 to +38
expect(label).toHaveClass('!bg-inherit');
});

it('strips newlines on paste in single-line input', () => {
const handleChange = vi.fn();
render(<TextField label='Test Field' onChange={handleChange} />);
Expand Down
10 changes: 9 additions & 1 deletion website/src/components/SearchPage/fields/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface TextFieldProps {

const helperTextClasses = getTheme().floatingLabel.helperText.default;
const inputClasses = getTheme().floatingLabel.input.default.outlined.md;
const labelClasses = getTheme().floatingLabel.label.default.outlined.md;

export const TextField = forwardRef<HTMLInputElement | HTMLTextAreaElement, TextFieldProps>(function (props, ref) {
const { label, disabled, onChange, autoComplete, fieldValue, className, onFocus, multiline, onBlur } = props;
Expand Down Expand Up @@ -138,6 +139,13 @@ export const TextField = forwardRef<HTMLInputElement | HTMLTextAreaElement, Text
},
},
},
label: {
default: {
outlined: {
md: `${labelClasses} !bg-inherit peer-placeholder-shown:!bg-transparent peer-focus:!bg-inherit`,
},
},
},
}}
{...inputProps}
variant='outlined'
Expand Down Expand Up @@ -173,7 +181,7 @@ export const TextField = forwardRef<HTMLInputElement | HTMLTextAreaElement, Text
htmlFor={id}
className={`absolute text-sm text-gray-500 dark:text-gray-400 pointer-events-none ${
isTransitionEnabled ? 'duration-300' : ''
} transform -translate-y-3 scale-75 top-1 z-10 origin-[0] bg-white dark:bg-gray-900 px-2 peer-focus:px-2 peer-focus:text-blue-600 peer-focus:dark:text-blue-500 peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-1 peer-focus:scale-75 peer-focus:-translate-y-3 start-1 rtl:peer-focus:translate-x-1/4 rtl:peer-focus:left-auto`}
} transform -translate-y-3 scale-75 top-1 z-10 origin-[0] !bg-inherit px-2 peer-focus:px-2 peer-focus:!bg-inherit peer-focus:text-blue-600 peer-focus:dark:text-blue-500 peer-placeholder-shown:!bg-transparent peer-placeholder-shown:scale-100 peer-placeholder-shown:-translate-y-1/2 peer-placeholder-shown:top-1/2 peer-focus:top-1 peer-focus:scale-75 peer-focus:-translate-y-3 start-1 rtl:peer-focus:translate-x-1/4 rtl:peer-focus:left-auto`}
>
{label}
</label>
Expand Down
Loading