Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(a11y): correct rest-spread precedence in Avatar components (#3903)

Cindy Zhanga845e8d6e7f7
diff --git a/packages/core/src/Avatar/Avatar.tsx b/packages/core/src/Avatar/Avatar.tsx
index 53546514ed..5e08086013 100644
--- a/packages/core/src/Avatar/Avatar.tsx
+++ b/packages/core/src/Avatar/Avatar.tsx
@@ -301,6 +301,7 @@ export function Avatar({
return (
<AvatarSizeContext value={numericSize}>
<div
+ {...props}
ref={ref}
role={isDecorative ? 'presentation' : 'img'}
aria-label={isDecorative ? undefined : accessibleName}
@@ -317,8 +318,7 @@ export function Avatar({
),
className,
style,
- )}
- {...props}>
+ )}>
<div {...stylex.props(styles.content, dynamicStyles.size(numericSize))}>
{showImage && (
<img
diff --git a/packages/core/src/Avatar/AvatarStatusDot.tsx b/packages/core/src/Avatar/AvatarStatusDot.tsx
index f38ca49602..d589724095 100644
--- a/packages/core/src/Avatar/AvatarStatusDot.tsx
+++ b/packages/core/src/Avatar/AvatarStatusDot.tsx
@@ -193,6 +193,7 @@ export function AvatarStatusDot({
return (
<div
+ {...props}
ref={ref}
{...(label ? {role: 'img', 'aria-label': label} : undefined)}
{...mergeProps(
@@ -205,8 +206,7 @@ export function AvatarStatusDot({
),
className,
style,
- )}
- {...props}>
+ )}>
{icon && iconSize > 0 && (
<span
aria-hidden="true"
diff --git a/packages/core/src/AvatarGroup/AvatarGroup.tsx b/packages/core/src/AvatarGroup/AvatarGroup.tsx
index 8d824ee3e6..e3cb445f45 100644
--- a/packages/core/src/AvatarGroup/AvatarGroup.tsx
+++ b/packages/core/src/AvatarGroup/AvatarGroup.tsx
@@ -94,6 +94,7 @@ export function AvatarGroup({
return (
<AvatarGroupContext value={contextValue}>
<div
+ {...props}
ref={ref}
role="group"
aria-label={ariaLabel}
@@ -103,8 +104,7 @@ export function AvatarGroup({
stylex.props(styles.root, xstyle),
className,
style,
- )}
- {...props}>
+ )}>
{children}
</div>
</AvatarGroupContext>
diff --git a/packages/core/src/AvatarGroup/AvatarGroupOverflow.tsx b/packages/core/src/AvatarGroup/AvatarGroupOverflow.tsx
index 03fdf7a589..3470f019c0 100644
--- a/packages/core/src/AvatarGroup/AvatarGroupOverflow.tsx
+++ b/packages/core/src/AvatarGroup/AvatarGroupOverflow.tsx
@@ -147,8 +147,8 @@ export function AvatarGroupOverflow({
ref={ref as React.Ref<HTMLButtonElement>}
type="button"
onClick={onClick}
- aria-label={label}
{...rest}
+ aria-label={label}
{...mergeProps(
themeProps('avatar-group-overflow'),
stylex.props(
@@ -171,8 +171,8 @@ export function AvatarGroupOverflow({
return (
<span
ref={ref}
- aria-label={label}
{...rest}
+ aria-label={label}
{...mergeProps(
themeProps('avatar-group-overflow'),
stylex.props(