Skip to content

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

TypeScript

fix(core): forward BaseProps pass-throughs in ContextMenu and CommandPaletteInput (#4650)

Cindy Zhang8dfd7cfe7323
diff --git a/packages/core/src/CommandPalette/CommandPaletteInput.tsx b/packages/core/src/CommandPalette/CommandPaletteInput.tsx
index 40932920c3..b67f25376f 100644
--- a/packages/core/src/CommandPalette/CommandPaletteInput.tsx
+++ b/packages/core/src/CommandPalette/CommandPaletteInput.tsx
@@ -163,6 +163,8 @@ export function CommandPaletteInput({
onKeyDown,
ref,
xstyle,
+ className,
+ style,
...props
}: CommandPaletteInputProps) {
const t = useTranslator();
@@ -207,6 +209,8 @@ export function CommandPaletteInput({
{...mergeProps(
themeProps('command-palette-input'),
stylex.props(styles.wrapper, xstyle),
+ className,
+ style,
)}>
<span {...stylex.props(styles.icon)}>
<Icon icon="search" size="sm" color="inherit" />
diff --git a/packages/core/src/ContextMenu/ContextMenu.tsx b/packages/core/src/ContextMenu/ContextMenu.tsx
index d9651c014f..ff850cca4e 100644
--- a/packages/core/src/ContextMenu/ContextMenu.tsx
+++ b/packages/core/src/ContextMenu/ContextMenu.tsx
@@ -220,12 +220,23 @@ export function ContextMenu({
xstyle,
triggerXstyle,
'data-testid': testId,
- ...props
+ ...rest
}: ContextMenuProps) {
const t = useTranslator();
const label = labelFromProps ?? t('@astryx.contextMenu.label');
- const items = ('items' in props ? props.items : undefined) ?? [];
- const menuContent = 'menuContent' in props ? props.menuContent : undefined;
+ // Separate content props (union discriminant) from DOM pass-through attrs.
+ // The union means exactly one of items/menuContent exists in rest; destructure
+ // both so triggerProps contains only DOM-safe attributes.
+ const {
+ items: itemsProp,
+ menuContent: menuContentProp,
+ ...triggerProps
+ } = rest as {items?: ContextMenuOption[]; menuContent?: ReactNode} & Omit<
+ typeof rest,
+ 'items' | 'menuContent'
+ >;
+ const items = itemsProp ?? [];
+ const menuContent = menuContentProp;
const menuId = useId();
// Cursor point in the trigger's local coordinate space (offset from the
@@ -449,7 +460,7 @@ export function ContextMenu({
);
const resolvedMenuContent =
- props.items !== undefined ? renderDropdownItems(items) : menuContent;
+ itemsProp !== undefined ? renderDropdownItems(items) : menuContent;
return (
<>
@@ -457,6 +468,7 @@ export function ContextMenu({
ref={mergeRefs(ref, triggerRef)}
onContextMenu={handleContextMenu}
{...longPressHandlers}
+ {...triggerProps}
data-testid={testId}
{...stylex.props(
styles.trigger,