Skip to content

Commit

Permalink
feat: focus search box in new tab page
Browse files Browse the repository at this point in the history
  • Loading branch information
sentialx committed Oct 1, 2019
1 parent c71ffa8 commit a76e312
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/dialogs/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface IOptions {
devtools?: boolean;
bounds?: IRectangle;
hideTimeout?: number;
customHide?: boolean;
}

interface IRectangle {
Expand Down
6 changes: 5 additions & 1 deletion src/main/view-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ipcMain } from 'electron';
import { TOOLBAR_HEIGHT } from '~/constants/design';
import { View } from './view';
import { AppWindow } from './windows';
import { NEWTAB_URL } from '~/constants/tabs';

export class ViewManager {
public views: View[] = [];
Expand Down Expand Up @@ -162,9 +163,12 @@ export class ViewManager {
this.window.addBrowserView(view);

this.window.menuDialog.hide();
this.window.searchDialog.hide();
this.window.findDialog.hide();

if (!view.webContents.getURL().startsWith(NEWTAB_URL)) {
this.window.searchDialog.hide();
}

this.fixBounds();
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export class View extends BrowserView {
this.webContents.addListener('did-start-navigation', (...args) => {
this.updateNavigationState();

this.favicon = '';

this.window.webContents.send(
`load-commit-${this.webContents.id}`,
...args,
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/views/app/models/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
TAB_PINNED_WIDTH,
} from '../constants';
import { getColorBrightness, callViewMethod } from '~/utils';
import { NEWTAB_URL } from '~/constants/tabs';

const isColorAcceptable = (color: string) => {
if (store.theme['tab.allowLightBackground']) {
Expand Down Expand Up @@ -300,6 +301,10 @@ export class ITab {
this.id,
this.findInfo,
);

if (this.url.startsWith(NEWTAB_URL)) {
ipcRenderer.send(`search-show-${store.windowId}`);
}
}

requestAnimationFrame(() => {
Expand Down

0 comments on commit a76e312

Please sign in to comment.