Skip to content
This repository was archived by the owner on Jun 26, 2026. It is now read-only.

Commit 88816f2

Browse files
matejvasekclaude
andcommitted
fix: consistent UserAvatar styling across all pages
The non-clickable UserAvatar (create/edit pages) rendered as a plain <span>, while the clickable variant (list page) rendered as a PF6 Button. This caused inconsistent visual placement inside ListPageHeader. Always render a Button variant="link", using isAriaDisabled to prevent interaction on non-clickable pages. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Matej Vašek <matejvasek@gmail.com>
1 parent d37f155 commit 88816f2

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

src/components/UserAvatar.test.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,16 @@ describe('UserAvatar', () => {
4141
expect(onClick).toHaveBeenCalled();
4242
});
4343

44-
it('non-clickable does not render button role', () => {
45-
render(<UserAvatar user={null} isClickable={false} onClick={jest.fn()} />);
44+
it('non-clickable renders as aria-disabled button that does not call onClick', async () => {
45+
const u = userEvent.setup();
46+
const onClick = jest.fn();
47+
48+
render(<UserAvatar user={null} isClickable={false} onClick={onClick} />);
49+
50+
const button = screen.getByRole('button', { name: 'Connect to GitHub' });
51+
expect(button).toHaveAttribute('aria-disabled', 'true');
4652

47-
expect(screen.queryByRole('button')).not.toBeInTheDocument();
53+
await u.click(button);
54+
expect(onClick).not.toHaveBeenCalled();
4855
});
4956
});

src/components/UserAvatar.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ export function UserAvatar({ user, isClickable, onClick }: UserAvatarProps) {
1515
const icon = user ? <UserIcon /> : <KeyIcon />;
1616
const label = user ? user.login : t('Connect to GitHub');
1717

18-
if (isClickable) {
19-
return (
20-
<Button variant="link" onClick={onClick} icon={icon}>
21-
{label}
22-
</Button>
23-
);
24-
}
25-
2618
return (
27-
<span>
28-
{icon} {label}
29-
</span>
19+
<Button
20+
variant="link"
21+
icon={icon}
22+
onClick={isClickable ? onClick : undefined}
23+
isAriaDisabled={!isClickable}
24+
style={!isClickable ? { cursor: 'default' } : undefined}
25+
>
26+
{label}
27+
</Button>
3028
);
3129
}

0 commit comments

Comments
 (0)