mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-01-08 05:49:49 -06:00
fix new tab open hiding
This commit is contained in:
@@ -13,6 +13,50 @@ export default class TabCachingWidget extends TabAwareWidget {
|
||||
return this.$widget = $(`<div class="marker" style="display: none;">`);
|
||||
}
|
||||
|
||||
async newTabOpenedEvent({tabContext}) {
|
||||
const {tabId} = tabContext;
|
||||
|
||||
if (this.widgets[tabId]) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.widgets[tabId] = this.widgetFactory();
|
||||
|
||||
const $renderedWidget = this.widgets[tabId].render();
|
||||
this.widgets[tabId].toggleExt(this.isTab(tabId));
|
||||
|
||||
this.$widget.after($renderedWidget);
|
||||
|
||||
keyboardActionsService.updateDisplayedShortcuts($renderedWidget);
|
||||
|
||||
await this.widgets[tabId].handleEvent('setTabContext', {tabContext});
|
||||
|
||||
this.child(this.widgets[tabId]); // add as child only once it is ready (rendered with tabContext)
|
||||
}
|
||||
|
||||
tabRemovedEvent({tabId}) {
|
||||
const widget = this.widgets[tabId];
|
||||
|
||||
if (widget) {
|
||||
widget.remove();
|
||||
delete this.widgets[tabId];
|
||||
|
||||
this.children = this.children.filter(ch => ch !== widget);
|
||||
}
|
||||
}
|
||||
|
||||
async refresh() {
|
||||
this.toggleExt(true);
|
||||
}
|
||||
|
||||
toggleInt(show) {} // not needed
|
||||
|
||||
toggleExt(show) {
|
||||
for (const tabId in this.widgets) {
|
||||
this.widgets[tabId].toggleExt(show && this.isTab(tabId));
|
||||
}
|
||||
}
|
||||
|
||||
handleEventInChildren(name, data) {
|
||||
// stop propagation of the event to the children, individual tab widget should not know about tab switching
|
||||
// since they are per-tab
|
||||
@@ -38,52 +82,4 @@ export default class TabCachingWidget extends TabAwareWidget {
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
async newTabOpenedEvent({tabContext}) {
|
||||
const {tabId} = tabContext;
|
||||
|
||||
if (this.widgets[tabId]) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.widgets[tabId] = this.widgetFactory();
|
||||
|
||||
const $renderedWidget = this.widgets[tabId].render();
|
||||
this.widgets[tabId].toggleExt(this.widgets[tabId]);
|
||||
|
||||
this.$widget.after($renderedWidget);
|
||||
|
||||
keyboardActionsService.updateDisplayedShortcuts($renderedWidget);
|
||||
|
||||
await this.widgets[tabId].handleEvent('setTabContext', {tabContext});
|
||||
|
||||
this.child(this.widgets[tabId]); // add as child only once it is ready (rendered with tabContext)
|
||||
}
|
||||
|
||||
async refresh() {
|
||||
const activeTabId = this.tabContext && this.tabContext.tabId;
|
||||
|
||||
for (const tabId in this.widgets) {
|
||||
this.widgets[tabId].toggleExt(tabId === activeTabId);
|
||||
}
|
||||
}
|
||||
|
||||
tabRemovedEvent({tabId}) {
|
||||
const widget = this.widgets[tabId];
|
||||
|
||||
if (widget) {
|
||||
widget.remove();
|
||||
delete this.widgets[tabId];
|
||||
|
||||
this.children = this.children.filter(ch => ch !== widget);
|
||||
}
|
||||
}
|
||||
|
||||
toggleInt(show) {} // not needed
|
||||
|
||||
toggleByTab(show) {
|
||||
for (const tabId in this.widgets) {
|
||||
this.widgets[tabId].toggleExt(show && this.isTab(tabId));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user