From cf57be8fb4648a1926153226c1df01a5bc759582 Mon Sep 17 00:00:00 2001 From: Katherine Date: Fri, 25 Apr 2025 15:05:26 +0800 Subject: [PATCH 1/5] fix: action panel icon missing when icon-only is enabled (#6773) --- .../src/client/WorkbenchAction.tsx | 45 ++++++++++--------- .../src/client/WorkbenchBlock.tsx | 1 + 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/packages/plugins/@nocobase/plugin-block-workbench/src/client/WorkbenchAction.tsx b/packages/plugins/@nocobase/plugin-block-workbench/src/client/WorkbenchAction.tsx index 56814c760d..65179849a1 100644 --- a/packages/plugins/@nocobase/plugin-block-workbench/src/client/WorkbenchAction.tsx +++ b/packages/plugins/@nocobase/plugin-block-workbench/src/client/WorkbenchAction.tsx @@ -42,31 +42,35 @@ const useStyles = createStyles(({ token, css }) => ({ `, })); -function Button() { +function Button({ onlyIcon }) { const fieldSchema = useFieldSchema(); - const icon = fieldSchema['x-component-props']?.['icon']; - const backgroundColor = fieldSchema['x-component-props']?.['iconColor']; + const { icon, iconColor: backgroundColor } = fieldSchema['x-component-props'] || {}; const { layout, ellipsis = true } = useContext(WorkbenchBlockContext); const { styles, cx } = useStyles(); const { t } = useTranslation(); const title = t(fieldSchema.title, { ns: NAMESPACE_UI_SCHEMA }); - return layout === WorkbenchLayout.Grid ? ( -
- } /> -
- {title} + + const shouldShowTitle = !onlyIcon; + + if (layout === WorkbenchLayout.Grid) { + return ( +
+ } /> +
+ {shouldShowTitle && title} +
-
- ) : ( - {title} - ); + ); + } + + return {shouldShowTitle && title}; } export const WorkbenchAction = withDynamicSchemaProps((props) => { @@ -79,9 +83,10 @@ export const WorkbenchAction = withDynamicSchemaProps((props) => { } + title={