Skip to content

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

TypeScript

fix(Icon,InputGroup): forward rest props in string mode and InputGroupText (#2885)

Cindy Zhang0b84a8d9b0e4
diff --git a/packages/core/src/Icon/XDSIcon.tsx b/packages/core/src/Icon/XDSIcon.tsx
index fd6ea35375..1c660640f9 100644
--- a/packages/core/src/Icon/XDSIcon.tsx
+++ b/packages/core/src/Icon/XDSIcon.tsx
@@ -224,7 +224,14 @@ export function XDSIcon({
}: XDSIconProps) {
// String mode: resolve from icon registry, wrap in styled span
if (typeof icon === 'string') {
- return <IconFromRegistry name={icon} color={color} size={size} />;
+ return (
+ <IconFromRegistry
+ name={icon}
+ color={color}
+ size={size}
+ spanProps={props}
+ />
+ );
}
// Component mode: render SVG component directly with ref forwarding
@@ -259,10 +266,12 @@ function IconFromRegistry({
name,
color,
size,
+ spanProps,
}: {
name: XDSIconName;
color: XDSIconColor;
size: XDSIconSize;
+ spanProps?: Omit<SVGProps<SVGSVGElement>, 'ref' | 'color'>;
}) {
const resolvedIcon = getIcon(name);
@@ -272,6 +281,7 @@ function IconFromRegistry({
return (
<span
+ {...(spanProps as React.HTMLAttributes<HTMLSpanElement>)}
{...mergeProps(
xdsThemeProps('icon', {size, color}),
stylex.props(styles.span, colorStyles[color], spanSizeStyles[size]),
diff --git a/packages/core/src/InputGroup/XDSInputGroupText.tsx b/packages/core/src/InputGroup/XDSInputGroupText.tsx
index 4623b43129..cf71c24e94 100644
--- a/packages/core/src/InputGroup/XDSInputGroupText.tsx
+++ b/packages/core/src/InputGroup/XDSInputGroupText.tsx
@@ -92,10 +92,12 @@ export function XDSInputGroupText({
xstyle,
className,
style,
+ ...rest
}: XDSInputGroupTextProps) {
return (
<div
ref={ref}
+ {...rest}
{...mergeProps(
xdsThemeProps('input-group-text'),
stylex.props(styles.text, xstyle),