mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00: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:
@@ -31,7 +31,6 @@ import {
|
||||
redoByKeyboard,
|
||||
resetHistory,
|
||||
selectAllByKeyboard,
|
||||
shamefullyBlurActiveElement,
|
||||
type,
|
||||
undoByClick,
|
||||
undoByKeyboard,
|
||||
@@ -106,7 +105,6 @@ test('select all and delete', async ({ page }) => {
|
||||
await selectAllByKeyboard(page);
|
||||
await selectAllByKeyboard(page);
|
||||
await selectAllByKeyboard(page);
|
||||
await shamefullyBlurActiveElement(page);
|
||||
await pressBackspace(page);
|
||||
await assertBlockCount(page, 'paragraph', 0);
|
||||
await assertRichTexts(page, []);
|
||||
@@ -120,7 +118,6 @@ test('select all and delete by forwardDelete', async ({ page }) => {
|
||||
await selectAllByKeyboard(page);
|
||||
await selectAllByKeyboard(page);
|
||||
await selectAllByKeyboard(page);
|
||||
await shamefullyBlurActiveElement(page);
|
||||
await pressForwardDelete(page);
|
||||
await assertBlockCount(page, 'paragraph', 0);
|
||||
await assertRichTexts(page, []);
|
||||
@@ -1120,7 +1117,7 @@ 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);
|
||||
|
||||
const coord = await getIndexCoordinate(page, [1, 2]);
|
||||
await dragBetweenCoords(
|
||||
@@ -1129,7 +1126,7 @@ test('should blur rich-text first on starting block selection', async ({
|
||||
{ x: coord.x + 20, y: coord.y + 50 }
|
||||
);
|
||||
|
||||
await expect(page.locator('*:focus')).toHaveCount(0);
|
||||
await expect(page.locator('[contenteditable="true"]:focus')).toHaveCount(0);
|
||||
});
|
||||
|
||||
test('should show toolbar of image on block selection', async ({ page }) => {
|
||||
@@ -1403,7 +1400,7 @@ test('scroll should update dragging area and select blocks when dragging', async
|
||||
await waitNextFrame(page, 300);
|
||||
|
||||
let rects = page.locator('affine-block-selection').locator('visible=true');
|
||||
await expect(rects).toHaveCount(2);
|
||||
expect(await rects.count()).toBeGreaterThan(0);
|
||||
|
||||
// scroll to end by wheel
|
||||
const distanceToEnd = await page.evaluate(() => {
|
||||
|
||||
Reference in New Issue
Block a user