Skip to content

Commit 0f76cd0

Browse files
committed
fix: prevent profile tooltips from opening on keyboard focus
Resolves accessibility issue where profile cards automatically opened popup tooltips when receiving keyboard focus, violating WCAG 2.1 guidelines. - Add trigger: 'mouseenter' to ProfileTooltip to prevent focus-triggered popups - Add keyboard navigation (Enter/Space) to open full profile pages - Add proper ARIA attributes for screen readers Fixes #1949
1 parent b6b8450 commit 0f76cd0

2 files changed

Lines changed: 36 additions & 8 deletions

File tree

packages/shared/src/components/profile/ProfileTooltip.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ export function ProfileTooltip({
122122
content: !isLoading && data ? <UserEntityCard user={data} /> : null,
123123
plugins:
124124
onTooltipMouseEnter || onTooltipMouseLeave ? [hoverPlugin] : undefined,
125+
// Remove focus from trigger to prevent keyboard accessibility issues
126+
trigger: 'mouseenter',
125127
...tooltip,
126128
onShow: (instance) => {
127129
if (id !== userId) {

packages/shared/src/components/profile/UserShortInfo.tsx

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ import { formatCoresCurrency } from '../../lib/utils';
2626
import { Image } from '../image/Image';
2727
import { ButtonVariant } from '../buttons/Button';
2828

29+
const getProfileUrl = (username: string): string => {
30+
return `https://app.daily.dev/${username}`;
31+
};
32+
2933
type PropsOf<Tag> = Tag extends keyof JSX.IntrinsicElements
3034
? JSX.IntrinsicElements[Tag]
3135
: Tag extends React.ComponentType<infer Props>
@@ -97,15 +101,37 @@ const UserShortInfoComponent = <Tag extends React.ElementType>(
97101
visible: disableTooltip ? false : undefined,
98102
};
99103

104+
const handleKeyDown = (event: React.KeyboardEvent) => {
105+
if ((event.key === 'Enter' || event.key === ' ') && !onClick) {
106+
event.preventDefault();
107+
// Navigate to full profile page instead of showing popup
108+
window.open(getProfileUrl(username), '_blank');
109+
}
110+
};
111+
112+
// Add proper keyboard accessibility
113+
const accessibilityProps =
114+
tag === 'a'
115+
? {}
116+
: {
117+
tabIndex: 0,
118+
role: 'button' as const,
119+
'aria-label': `View ${name}'s profile`,
120+
onKeyDown: handleKeyDown,
121+
};
122+
123+
const elementProps = {
124+
ref,
125+
...props,
126+
className: classNames(
127+
'flex flex-row',
128+
className.container ?? defaultClassName.container,
129+
),
130+
...accessibilityProps,
131+
};
132+
100133
return (
101-
<Element
102-
ref={ref}
103-
{...props}
104-
className={classNames(
105-
'flex flex-row',
106-
className.container ?? defaultClassName.container,
107-
)}
108-
>
134+
<Element {...elementProps}>
109135
<ProfileTooltip
110136
userId={user?.id}
111137
tooltip={tooltipProps}

0 commit comments

Comments
 (0)