Skip to content

Commit 631814d

Browse files
Copilothotlong
andcommitted
refactor: extract overflow menu rendering from IIFE to variable in ActionBar
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 0c84911 commit 631814d

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

packages/components/src/renderers/action/action-bar.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,19 @@ const ActionBarRenderer = forwardRef<HTMLDivElement, { schema: ActionBarSchema;
9898
const direction = schema.direction || 'horizontal';
9999
const gap = schema.gap || 'gap-2';
100100

101+
// Render overflow menu for excess actions
102+
const MenuRenderer = overflowActions.length > 0 ? ComponentRegistry.get('action:menu') : null;
103+
const overflowMenu = MenuRenderer ? (
104+
<MenuRenderer
105+
schema={{
106+
type: 'action:menu' as const,
107+
actions: overflowActions,
108+
variant: schema.variant || 'ghost',
109+
size: schema.size || 'sm',
110+
}}
111+
/>
112+
) : null;
113+
101114
return (
102115
<div
103116
ref={ref}
@@ -131,20 +144,7 @@ const ActionBarRenderer = forwardRef<HTMLDivElement, { schema: ActionBarSchema;
131144
);
132145
})}
133146

134-
{overflowActions.length > 0 && (() => {
135-
const MenuRenderer = ComponentRegistry.get('action:menu');
136-
if (!MenuRenderer) return null;
137-
return (
138-
<MenuRenderer
139-
schema={{
140-
type: 'action:menu' as const,
141-
actions: overflowActions,
142-
variant: schema.variant || 'ghost',
143-
size: schema.size || 'sm',
144-
}}
145-
/>
146-
);
147-
})()}
147+
{overflowActions.length > 0 && overflowMenu}
148148
</div>
149149
);
150150
},

0 commit comments

Comments
 (0)