mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
web: don't close pinned tab on ctrl+w (#7805)
* web: don't close pinned tab on ctrl+w Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com> * web: focus previously activated tab if ctrl+w on pinned tab Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
@@ -97,8 +97,16 @@ const KEYMAP = [
|
||||
},
|
||||
{
|
||||
keys: ["ctrl+w", "command+w"],
|
||||
description: "Close active tab",
|
||||
action: () => useEditorStore.getState().closeActiveTab()
|
||||
description:
|
||||
"Close active tab or focus previously activated tab if active tab pinned",
|
||||
action: () => {
|
||||
const activeTab = useEditorStore.getState().getActiveTab();
|
||||
if (activeTab?.pinned) {
|
||||
useEditorStore.getState().focusLastActiveTab();
|
||||
return;
|
||||
}
|
||||
useEditorStore.getState().closeActiveTab();
|
||||
}
|
||||
},
|
||||
{
|
||||
keys: ["ctrl+shift+w", "command+shift+w"],
|
||||
|
||||
@@ -850,6 +850,16 @@ class EditorStore extends BaseStore<EditorStore> {
|
||||
return this.focusTab(tabs[index === 0 ? tabs.length - 1 : index - 1].id);
|
||||
};
|
||||
|
||||
focusLastActiveTab = () => {
|
||||
const history = useEditorStore.getState().history;
|
||||
if (history.length < 2) return;
|
||||
|
||||
const previousTab = history.at(-2);
|
||||
if (!previousTab) return;
|
||||
|
||||
useEditorStore.getState().focusTab(previousTab);
|
||||
};
|
||||
|
||||
goBack = async () => {
|
||||
const activeTabId = this.get().activeTabId;
|
||||
if (!activeTabId || !tabSessionHistory.canGoBack(activeTabId)) return;
|
||||
|
||||
Reference in New Issue
Block a user