From 5ed8541cb15ce9ede4a57a34a7decdc9ebfe3065 Mon Sep 17 00:00:00 2001 From: fundon Date: Wed, 12 Mar 2025 16:54:02 +0000 Subject: [PATCH] fix(editor): should directly return the sub-action content if it exists (#10778) --- .../widgets/widget-toolbar/src/utils.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/blocksuite/affine/widgets/widget-toolbar/src/utils.ts b/blocksuite/affine/widgets/widget-toolbar/src/utils.ts index 9978e9dc0..b99f59fa4 100644 --- a/blocksuite/affine/widgets/widget-toolbar/src/utils.ts +++ b/blocksuite/affine/widgets/widget-toolbar/src/utils.ts @@ -240,11 +240,11 @@ function renderActions( return actions .map(action => { let content: TemplateResult | null = null; - if ('content' in action && action.content) { + if ('content' in action) { if (typeof action.content === 'function') { content = action.content(context); } else { - content = action.content; + content = action.content ?? null; } return content; } @@ -254,12 +254,21 @@ function renderActions( if (!combined.length) return content; - const ordered = orderBy(combined, ['score', 'id'], ['asc', 'asc']); + const ordered = orderBy(combined, ['id', 'score'], ['asc', 'asc']); return repeat( ordered, - b => b.id, - b => render(b, context) + a => a.id, + a => { + if ('content' in a) { + if (typeof a.content === 'function') { + return a.content(context); + } else { + return a.content ?? null; + } + } + return render(a, context); + } ); }