Skip to content

Commit 2663c25

Browse files
fix(website): restore floated text field label background (#6505)
Fixes regression from #6482, where labels became transparent in the floated state for wrapped search text fields. Before: <img width="305" height="102" alt="Google Chrome 2026-05-27 15 37 28" src="https://github.com/user-attachments/assets/da19b6ad-49ad-42b0-9c87-7aa97a08a9dc" /> After: <img width="268" height="74" alt="Google Chrome 2026-05-27 15 39 52" src="https://github.com/user-attachments/assets/14f24589-3743-4bef-b1df-f514890a53bd" /> 🚀 Preview: https://fix-label-transp.loculus.org
1 parent f749a3b commit 2663c25

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

website/src/components/SearchPage/fields/TextField.spec.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,22 @@ describe('TextField', () => {
3131
expect(handleChange).toHaveBeenCalled();
3232
});
3333

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

3737
const label = screen.getByText('Test Field');
3838
expect(label).toHaveClass('peer-placeholder-shown:!bg-transparent');
39-
expect(label).toHaveClass('!bg-inherit');
39+
expect(label).toHaveClass('!bg-white');
40+
expect(label).toHaveClass('peer-focus:!bg-white');
41+
});
42+
43+
it('applies transparent background only in placeholder state for multiline labels', () => {
44+
render(<TextField label='Test Field' multiline={true} />);
45+
46+
const label = screen.getByText('Test Field');
47+
expect(label).toHaveClass('peer-placeholder-shown:!bg-transparent');
48+
expect(label).toHaveClass('!bg-white');
49+
expect(label).toHaveClass('peer-focus:!bg-white');
4050
});
4151

4252
it('strips newlines on paste in single-line input', () => {

website/src/components/SearchPage/fields/TextField.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export const TextField = forwardRef<HTMLInputElement | HTMLTextAreaElement, Text
142142
label: {
143143
default: {
144144
outlined: {
145-
md: `${labelClasses} !bg-inherit peer-placeholder-shown:!bg-transparent peer-focus:!bg-inherit`,
145+
md: `${labelClasses} !bg-white dark:!bg-gray-900 peer-placeholder-shown:!bg-transparent peer-focus:!bg-white peer-focus:dark:!bg-gray-900`,
146146
},
147147
},
148148
},
@@ -181,7 +181,7 @@ export const TextField = forwardRef<HTMLInputElement | HTMLTextAreaElement, Text
181181
htmlFor={id}
182182
className={`absolute text-sm text-gray-500 dark:text-gray-400 pointer-events-none ${
183183
isTransitionEnabled ? 'duration-300' : ''
184-
} 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`}
184+
} 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:!bg-white peer-focus:dark:!bg-gray-900 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`}
185185
>
186186
{label}
187187
</label>

0 commit comments

Comments
 (0)