From a5cbb306c4076bf94959d85007eddfbe28845ccb Mon Sep 17 00:00:00 2001 From: CommaBot Date: Tue, 24 Nov 2026 17:56:11 +0800 Subject: [PATCH] fix(editor): do not open the icon picker on every click in a callout without icon (#15906) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the icon of a callout was removed, any click inside the callout, including clicks meant to place the caret in its text, opened the icon picker. The icon can still be added back from the callout toolbar. fix #15292 ## Summary by CodeRabbit * **Bug Fixes** * Clicking the text area of a callout without an icon no longer opens the icon picker. Clicking an existing icon continues to open the picker, while clicks on the icon’s emoji area remain unaffected. * **Tests** * Added coverage for icon-picker behavior when clicking callout icons and text areas, with and without an icon. Co-authored-by: DarkSky --- .../blocks/callout/src/callout-block.ts | 7 ---- .../__tests__/main/editor-semantics.spec.ts | 39 +++++++++++++++++++ 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/blocksuite/affine/blocks/callout/src/callout-block.ts b/blocksuite/affine/blocks/callout/src/callout-block.ts index 76f3415f46..34ec54ffd0 100644 --- a/blocksuite/affine/blocks/callout/src/callout-block.ts +++ b/blocksuite/affine/blocks/callout/src/callout-block.ts @@ -166,13 +166,6 @@ export class CalloutBlockComponent extends CaptionedBlockComponent 0) { return; diff --git a/blocksuite/integration-test/src/__tests__/main/editor-semantics.spec.ts b/blocksuite/integration-test/src/__tests__/main/editor-semantics.spec.ts index d245830487..fa6ae2d61b 100644 --- a/blocksuite/integration-test/src/__tests__/main/editor-semantics.spec.ts +++ b/blocksuite/integration-test/src/__tests__/main/editor-semantics.spec.ts @@ -15,6 +15,10 @@ import type { } from '@blocksuite/affine-model'; import { insertContent } from '@blocksuite/affine-rich-text'; import { REFERENCE_NODE } from '@blocksuite/affine-shared/consts'; +import { + IconPickerServiceIdentifier, + IconType, +} from '@blocksuite/affine-shared/services'; import type { AffineTextAttributes } from '@blocksuite/affine-shared/types'; import { createDefaultDoc } from '@blocksuite/affine-shared/utils'; import type { SingleViewBase } from '@blocksuite/data-view'; @@ -270,6 +274,41 @@ test('typing into a sorted database title keeps editing the same row', async () expect(titleCells[0].dataset.editing).toBe('true'); }); +test.each([ + { hasIcon: true, target: '[data-testid="callout-emoji"]', opened: true }, + { hasIcon: true, target: 'rich-text', opened: false }, + { hasIcon: false, target: 'rich-text', opened: false }, +])( + 'clicking $target in a callout (icon: $hasIcon) opens the icon picker: $opened', + async ({ hasIcon, target, opened }) => { + await setupEditor('page', [ + { + setup: di => { + di.override(IconPickerServiceIdentifier, () => ({ + iconPickerComponent: () => ({ update() {}, unmount() {} }), + })); + }, + }, + ]); + const noteId = addNote(doc); + const calloutId = doc.addBlock( + 'affine:callout', + { icon: hasIcon ? { type: IconType.Emoji, unicode: '💡' } : undefined }, + noteId + ); + doc.addBlock('affine:paragraph', { text: new Text('text') }, calloutId); + await wait(); + editor + .host!.view.getBlock(calloutId)! + .querySelector(target)! + .click(); + await wait(); + expect(editor.host!.querySelector('icon-picker-wrapper') !== null).toBe( + opened + ); + } +); + test.each(['page', 'edgeless'] as const)( 'table selection preserves its input owner in %s mode', async mode => {