Skip to content

Commit ae3b13b

Browse files
committed
fix(electron): only the active view should respond to CMD+N (#8068)
1 parent aad442e commit ae3b13b

File tree

1 file changed

+14
-2
lines changed
  • packages/frontend/core/src/components/root-app-sidebar

1 file changed

+14
-2
lines changed

packages/frontend/core/src/components/root-app-sidebar/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { ExplorerTags } from '@affine/core/modules/explorer/views/sections/tags';
1212
import { CMDKQuickSearchService } from '@affine/core/modules/quicksearch/services/cmdk';
1313
import { isNewTabTrigger } from '@affine/core/utils';
14-
import { events } from '@affine/electron-api';
14+
import { apis, events } from '@affine/electron-api';
1515
import { useI18n } from '@affine/i18n';
1616
import type { DocMode } from '@blocksuite/blocks';
1717
import {
@@ -122,7 +122,19 @@ export const RootAppSidebar = (): ReactElement => {
122122

123123
useEffect(() => {
124124
if (environment.isDesktop) {
125-
return events?.applicationMenu.onNewPageAction(() => onClickNewPage());
125+
return events?.applicationMenu.onNewPageAction(() => {
126+
apis?.ui
127+
.isActiveTab()
128+
.then(isActive => {
129+
if (!isActive) {
130+
return;
131+
}
132+
onClickNewPage();
133+
})
134+
.catch(err => {
135+
console.error(err);
136+
});
137+
});
126138
}
127139
return;
128140
}, [onClickNewPage]);

0 commit comments

Comments
 (0)