Skip to content

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

TypeScript

fix(core): Code and CommandPaletteEmpty prop forwarding (#3620)

Cindy Zhang94ccccc68055
diff --git a/.changeset/code-empty-props.md b/.changeset/code-empty-props.md
new file mode 100644
index 0000000000..1ae40f5b85
--- /dev/null
+++ b/.changeset/code-empty-props.md
@@ -0,0 +1,9 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Code and CommandPaletteEmpty now forward props correctly (#3620)
+
+`Code` spreads rest props (`aria-*`, `role`, event handlers) onto the DOM element. `CommandPaletteEmpty` applies the `xstyle`/`className`/`style` escape hatches and theme props.
+
+@cixzhang
diff --git a/packages/core/src/Code/Code.tsx b/packages/core/src/Code/Code.tsx
index 69bd346af2..4f6da5bf6d 100644
--- a/packages/core/src/Code/Code.tsx
+++ b/packages/core/src/Code/Code.tsx
@@ -112,6 +112,7 @@ export function Code({
return (
<code
ref={ref}
+ {...props}
{...mergeProps(
themeProps('code', {color}),
stylex.props(
@@ -122,8 +123,7 @@ export function Code({
),
className,
style,
- )}
- data-testid={props['data-testid']}>
+ )}>
{children}
</code>
);
diff --git a/packages/core/src/CommandPalette/CommandPaletteEmpty.tsx b/packages/core/src/CommandPalette/CommandPaletteEmpty.tsx
index 45a5be544d..df41d46602 100644
--- a/packages/core/src/CommandPalette/CommandPaletteEmpty.tsx
+++ b/packages/core/src/CommandPalette/CommandPaletteEmpty.tsx
@@ -20,7 +20,9 @@ import {
typeScaleVars,
typographyVars,
} from '../theme/tokens.stylex';
+import {mergeProps} from '../utils';
import type {BaseProps} from '../BaseProps';
+import {themeProps} from '../utils/themeProps';
const styles = stylex.create({
empty: {
@@ -64,9 +66,21 @@ export interface CommandPaletteEmptyProps extends BaseProps<HTMLDivElement> {
export function CommandPaletteEmpty({
ref,
children,
+ xstyle,
+ className,
+ style,
+ ...props
}: CommandPaletteEmptyProps) {
return (
- <div ref={ref} {...stylex.props(styles.empty)}>
+ <div
+ ref={ref}
+ {...mergeProps(
+ themeProps('command-palette-empty'),
+ stylex.props(styles.empty, xstyle),
+ className,
+ style,
+ )}
+ {...props}>
{children}
</div>
);