mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
fix(editor): auto focus between tab switch (#12572)
Closes: BS-2290 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Summary by CodeRabbit - **Bug Fixes** - Improved focus behavior when switching between tabs to prevent unwanted automatic focusing of the content-editable area. - Enhanced selection clearing to avoid unnecessary blurring when the main editable element is already focused. - Refined focus checks in tests to specifically target contenteditable elements, ensuring more accurate validation of focus behavior. - Adjusted test assertions for block selection to be less strict and removed redundant blur operations for smoother test execution. - Updated toolbar dropdown closing method to use keyboard interaction for better reliability. - **New Features** - Added a recoverable property to selection types, improving selection state management and recovery. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -346,13 +346,13 @@ test('should blur rich-text first on starting block selection', async ({
|
||||
await initThreeParagraphs(page);
|
||||
await assertRichTexts(page, ['123', '456', '789']);
|
||||
|
||||
await expect(page.locator('*:focus')).toHaveCount(1);
|
||||
await expect(page.locator('[contenteditable="true"]:focus')).toHaveCount(1);
|
||||
|
||||
await dragHandleFromBlockToBlockBottomById(page, '2', '4');
|
||||
await expect(page.locator('.affine-drop-indicator')).toBeHidden();
|
||||
await assertRichTexts(page, ['456', '789', '123']);
|
||||
|
||||
await expect(page.locator('*:focus')).toHaveCount(0);
|
||||
await expect(page.locator('[contenteditable="true"]:focus')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('hide drag handle when mouse is hovering over the title', async ({
|
||||
@@ -490,7 +490,7 @@ test('should trigger click event on editor container when clicking on blocks und
|
||||
.locator('affine-block-selection')
|
||||
.locator('visible=true');
|
||||
await expect(blockSelections).toHaveCount(2);
|
||||
await expect(page.locator('*:focus')).toHaveCount(0);
|
||||
await expect(page.locator('[contenteditable="true"]:focus')).toHaveCount(0);
|
||||
|
||||
const editorHost = getEditorHostLocator(page);
|
||||
const editors = editorHost.locator('rich-text');
|
||||
@@ -506,7 +506,7 @@ test('should trigger click event on editor container when clicking on blocks und
|
||||
await page.mouse.down();
|
||||
await page.mouse.up();
|
||||
await expect(blockSelections).toHaveCount(0);
|
||||
await expect(page.locator('*:focus')).toHaveCount(1);
|
||||
await expect(page.locator('[contenteditable="true"]:focus')).toHaveCount(1);
|
||||
});
|
||||
|
||||
test('should get to selected block when dragging unselected block', async ({
|
||||
|
||||
Reference in New Issue
Block a user