mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-12 23:56:36 +08:00
fix(editor): should exit drawing tools menu when Escape is pressed (#11306)
Closes: [BS-2978](https://linear.app/affine-design/issue/BS-2978/二级菜单的激活状态错误) [BS-2977](https://linear.app/affine-design/issue/BS-2977/pen和highlighter没做esc)
This commit is contained in:
@@ -87,6 +87,15 @@ export class EdgelessPenToolButton extends EdgelessToolbarToolMixin(
|
||||
|
||||
override type: Pen[] = ['brush', 'highlighter'];
|
||||
|
||||
override firstUpdated() {
|
||||
this.disposables.add(
|
||||
this.gfx.tool.currentToolName$.subscribe(tool => {
|
||||
if (this.type.map(String).includes(tool)) return;
|
||||
this.tryDisposePopper();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private _togglePenMenu() {
|
||||
if (this.tryDisposePopper()) return;
|
||||
!this.active && this.setEdgelessTool(this.pen$.peek());
|
||||
|
||||
@@ -43,3 +43,17 @@ test('should add highlighter', async ({ page }) => {
|
||||
|
||||
expect(defaultLineWidth).toBe('22');
|
||||
});
|
||||
|
||||
test('should exit drawing tools menu when Escape is pressed', async ({
|
||||
page,
|
||||
}) => {
|
||||
await setEdgelessTool(page, 'highlighter');
|
||||
|
||||
const drawingToolsMenu = page.locator('edgeless-pen-menu');
|
||||
|
||||
await expect(drawingToolsMenu).toBeVisible();
|
||||
|
||||
await page.keyboard.press('Escape');
|
||||
|
||||
await expect(drawingToolsMenu).toBeHidden();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user