fix(core): stuck when quick switch doc mode (#7599)
This commit is contained in:
@@ -181,8 +181,6 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
|||||||
const pageService =
|
const pageService =
|
||||||
editorHost?.std.spec.getService<PageRootService>('affine:page');
|
editorHost?.std.spec.getService<PageRootService>('affine:page');
|
||||||
const disposable = new DisposableGroup();
|
const disposable = new DisposableGroup();
|
||||||
|
|
||||||
doc.setMode(mode);
|
|
||||||
if (pageService) {
|
if (pageService) {
|
||||||
disposable.add(
|
disposable.add(
|
||||||
pageService.slots.docLinkClicked.on(({ docId, blockId }) => {
|
pageService.slots.docLinkClicked.on(({ docId, blockId }) => {
|
||||||
@@ -204,15 +202,7 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
|||||||
disposable.dispose();
|
disposable.dispose();
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
[
|
[jumpToPageBlock, docCollection.id, openPage, jumpToTag, workspace.id]
|
||||||
doc,
|
|
||||||
mode,
|
|
||||||
jumpToPageBlock,
|
|
||||||
docCollection.id,
|
|
||||||
openPage,
|
|
||||||
jumpToTag,
|
|
||||||
workspace.id,
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import { test } from '@affine-test/kit/playwright';
|
import { test } from '@affine-test/kit/playwright';
|
||||||
|
import {
|
||||||
|
ensureInEdgelessMode,
|
||||||
|
ensureInPageMode,
|
||||||
|
getPageMode,
|
||||||
|
} from '@affine-test/kit/utils/editor';
|
||||||
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
||||||
import {
|
import {
|
||||||
clickNewPageButton,
|
clickNewPageButton,
|
||||||
@@ -55,6 +60,40 @@ test('Switch to edgeless by switch edgeless item', async ({ page }) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Quick Switch Doc Mode, Doc Mode should stable', async ({ page }) => {
|
||||||
|
await openHomePage(page);
|
||||||
|
await waitForEditorLoad(page);
|
||||||
|
await ensureInEdgelessMode(page);
|
||||||
|
await page.keyboard.down('Alt');
|
||||||
|
await page.keyboard.down('S');
|
||||||
|
await page.keyboard.up('S');
|
||||||
|
await page.keyboard.up('Alt');
|
||||||
|
|
||||||
|
await page.keyboard.down('Alt');
|
||||||
|
await page.keyboard.down('S');
|
||||||
|
await page.keyboard.up('S');
|
||||||
|
await page.keyboard.up('Alt');
|
||||||
|
|
||||||
|
await page.keyboard.down('Alt');
|
||||||
|
await page.keyboard.down('S');
|
||||||
|
await page.keyboard.up('S');
|
||||||
|
await page.keyboard.up('Alt');
|
||||||
|
|
||||||
|
await page.keyboard.down('Alt');
|
||||||
|
await page.keyboard.down('S');
|
||||||
|
await page.keyboard.up('S');
|
||||||
|
await page.keyboard.up('Alt');
|
||||||
|
|
||||||
|
await page.keyboard.down('Alt');
|
||||||
|
await page.keyboard.down('S');
|
||||||
|
await page.keyboard.up('S');
|
||||||
|
await page.keyboard.up('Alt');
|
||||||
|
|
||||||
|
await ensureInPageMode(page);
|
||||||
|
await page.waitForTimeout(1000);
|
||||||
|
expect(await getPageMode(page)).toBe('page');
|
||||||
|
});
|
||||||
|
|
||||||
test('Convert to edgeless by editor header items', async ({ page }) => {
|
test('Convert to edgeless by editor header items', async ({ page }) => {
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
|
|||||||
@@ -19,3 +19,37 @@ export async function clickPageModeButton(page: Page) {
|
|||||||
page.locator('[data-testid="switch-page-mode-button"][data-active="true"]')
|
page.locator('[data-testid="switch-page-mode-button"][data-active="true"]')
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function ensureInPageMode(page: Page) {
|
||||||
|
await expect(
|
||||||
|
page.locator('[data-testid="switch-page-mode-button"][data-active="true"]')
|
||||||
|
).toBeVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function ensureInEdgelessMode(page: Page) {
|
||||||
|
await expect(
|
||||||
|
page.locator(
|
||||||
|
'[data-testid="switch-edgeless-mode-button"][data-active="true"]'
|
||||||
|
)
|
||||||
|
).toBeVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getPageMode(page: Page): Promise<'page' | 'edgeless'> {
|
||||||
|
if (
|
||||||
|
await page
|
||||||
|
.locator('[data-testid="switch-page-mode-button"][data-active="true"]')
|
||||||
|
.isVisible()
|
||||||
|
) {
|
||||||
|
return 'page';
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
await page
|
||||||
|
.locator(
|
||||||
|
'[data-testid="switch-edgeless-mode-button"][data-active="true"]'
|
||||||
|
)
|
||||||
|
.isVisible()
|
||||||
|
) {
|
||||||
|
return 'edgeless';
|
||||||
|
}
|
||||||
|
throw new Error('Unknown mode');
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user