fix(editor): close embed edit modal on editor unmount (#9765)

Close [BS-2436](https://linear.app/affine-design/issue/BS-2436/should-close-embed-card-edit-modal-after-editor-unmount)

### What Changes:
- fix(editor): close embed edit modal on editor unmount
- test(editor): add test to embed edit modal when switching mode
This commit is contained in:
L-Sun
2025-01-17 11:53:09 +00:00
parent df910d7013
commit d8727c2001
2 changed files with 43 additions and 0 deletions
@@ -279,6 +279,7 @@ export class EmbedCardEditModal extends SignalWatcher(
override connectedCallback() {
super.connectedCallback();
this.disposables.add(this.host.slots.unmounted.on(this._hide));
this._updateInfo();
}
@@ -0,0 +1,42 @@
import { test } from '@affine-test/kit/playwright';
import {
clickEdgelessModeButton,
locateEditorContainer,
locateElementToolbar,
} from '@affine-test/kit/utils/editor';
import { openHomePage } from '@affine-test/kit/utils/load-page';
import {
clickNewPageButton,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test';
const title = 'Edgeless Note Header Test';
test.beforeEach(async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await clickNewPageButton(page, title);
await clickEdgelessModeButton(page);
const container = locateEditorContainer(page);
await container.click();
});
test('should close embed editing modal when editor switching to page mode by short cut', async ({
page,
}) => {
await page.keyboard.press('@');
await page
.getByTestId('cmdk-label')
.getByText('Write, Draw, Plan all at Once.')
.click();
const toolbar = locateElementToolbar(page);
await toolbar.getByLabel('Edit').click();
const editingModal = page.locator('embed-card-edit-modal');
expect(editingModal).toBeVisible();
await page.keyboard.press('Alt+s');
await waitForEditorLoad(page);
expect(editingModal).toBeHidden();
});