Commit 9e5a45b7 authored by Laurent Wouters's avatar Laurent Wouters
Browse files

[fix] Fixed sidebar toggle

parent f2fa5a56dc9d
......@@ -28,7 +28,7 @@ export interface CurrentTabMenuProps {
onSelectView: (viewId: string) => void;
onClickGotoCurrentTab: () => void;
onClickGotoOptions: () => void;
onClickGotoSidebar: () => void;
onClickToggleSidebar: () => void;
}
export class CurrentTabMenu extends React.Component<CurrentTabMenuProps, {}> {
......@@ -82,10 +82,10 @@ export class CurrentTabMenu extends React.Component<CurrentTabMenuProps, {}> {
<div className="col-12">
<a
className="btn btn-outline-light"
onClick={this.props.onClickGotoSidebar}
title={"Open info sidebar"}
onClick={this.props.onClickToggleSidebar}
title={"Toggle info sidebar"}
>
Open info sidebar ...
Toggle info sidebar ...
</a>
</div>
</div>
......
......@@ -19,8 +19,17 @@
******************************************************************************/
declare namespace chrome.sidebarAction {
/**
* Returns true if the extension's sidebar is open in a given window.
* @param details An object optionally containing the windowId to check.
*/
function isOpen(details: { windowId?: number }): Promise<boolean>;
/**
* Open the sidebar in the active window.
*/
function open(): Promise<void>;
/**
* Closes the sidebar in the active window, if it is the extension's own sidebar.
*/
function close(): Promise<void>;
}
......@@ -73,7 +73,7 @@ class Popup extends React.Component<{}, State> {
registry: null
};
this.onOpenOptions = this.onOpenOptions.bind(this);
this.onOpenSidebar = this.onOpenSidebar.bind(this);
this.onToggleSidebar = this.onToggleSidebar.bind(this);
this.onTunOff = this.onTunOff.bind(this);
this.onDisplayRaw = this.onDisplayRaw.bind(this);
this.onUpdateTabCommand = this.onUpdateTabCommand.bind(this);
......@@ -101,8 +101,11 @@ class Popup extends React.Component<{}, State> {
chrome.runtime.openOptionsPage(() => {});
}
onOpenSidebar() {
chrome.sidebarAction.open();
onToggleSidebar() {
chrome.sidebarAction.isOpen({}).then((isOpen: boolean) => {
if (isOpen) chrome.sidebarAction.close();
else chrome.sidebarAction.open();
});
}
onTunOff() {
......@@ -170,7 +173,7 @@ class Popup extends React.Component<{}, State> {
self.setState(self.state);
}}
onClickGotoOptions={this.onOpenOptions}
onClickGotoSidebar={this.onOpenSidebar}
onClickToggleSidebar={this.onToggleSidebar}
onSelectView={(viewId: string) => {
this.state.data.command.isAutomatic = false;
this.state.data.command.selectedView = viewId;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment