Skip to content

Commit

Permalink
fix: tab sizing for user interactions and adds focus to new tabs
Browse files Browse the repository at this point in the history
* Fixed tab sizing for user interactions.

* Fixed/added focus to newly opened tabs.
  • Loading branch information
Claudio Gomes committed Mar 19, 2022
1 parent 57606ac commit 512e42e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 14 additions & 1 deletion src/main/window/WindowManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class WindowManager {
figmaUiScale: number;
panelScale: number;
closedTabsHistory: Array<string> = [];
tabsWereRestored: boolean;
themes: Themes.Theme[] = [];
currentTheme: Themes.Theme;
creatorTheme: Themes.Theme;
Expand All @@ -64,6 +65,7 @@ class WindowManager {
this.figmaUiScale = storage.get().ui.scaleFigmaUI;
this.panelScale = storage.get().ui.scalePanel;
this.figmaUserIDs = storage.get().authedUserIDs;
this.tabsWereRestored = false;

const options: E.BrowserWindowConstructorOptions = {
width: 1200,
Expand Down Expand Up @@ -151,12 +153,17 @@ class WindowManager {
tabs.forEach((tab, i) => {
setTimeout(() => {
this.addTab("loadContent.js", tab.url, tab.title);
if (i === tabs.length - 1) {
this.tabsWereRestored = true;
}
}, 500 * i);
});

storage.clearLastOpenedTabs();

MenuState.updateInFileBrowserActionState();
} else {
this.tabsWereRestored = true;
}
};

Expand Down Expand Up @@ -670,12 +677,18 @@ class WindowManager {
MenuState.updateActionState(Const.ACTIONTABSTATE);

this.mainWindow.addBrowserView(tab.view);
this.mainWindow.setTopBrowserView(this.mainTab);
if (this.lastFocusedTab && this.tabsWereRestored && this.lastFocusedTab.id !== tab.view.webContents.id) {
this.focusTab(tab.view.webContents.id);
} else {
this.focusMainTab();
}
this.mainWindow.webContents.send("didTabAdd", {
id: tab.view.webContents.id,
url,
showBackBtn: true,
title,
focused:
this.lastFocusedTab && this.tabsWereRestored ? this.lastFocusedTab.id === tab.view.webContents.id : false,
});

tab.view.webContents.session.setPermissionRequestHandler((webContents, permission, cb) => {
Expand Down
3 changes: 1 addition & 2 deletions src/renderer/components/Tabs/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
background-color: var(--bg-tab);
color: var(--fg-tab);
fill: var(--fg-tab);
-webkit-app-region: no-drag;

&:hover {
background-color: var(--bg-tab-hover);
Expand All @@ -37,7 +38,6 @@
font-size: var(--fontControlSize);
margin-right: 6px;
opacity: 0.4;
-webkit-app-region: no-drag;
}

&:hover .tab__text {
Expand All @@ -50,7 +50,6 @@
fill: var(--fg-tab);
opacity: 0;
display: inline-flex;
-webkit-app-region: no-drag;

&:hover {
color: var(--fg-tab-hover);
Expand Down

0 comments on commit 512e42e

Please sign in to comment.