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:
fundon
2025-03-31 11:05:01 +00:00
parent 2f1f09e25f
commit f1882061a2
2 changed files with 23 additions and 0 deletions

View File

@@ -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());