Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed crash on slim sidebar toggle #113

Merged
merged 2 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "opengis",
"homepage": "https://opengis.simcoe.ca/public/",
"version": "1.0.10",
"version": "1.0.11",
"private": true,
"dependencies": {
"array-move": "^2.2.2",
Expand Down
27 changes: 9 additions & 18 deletions src/sidebar/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -348,21 +348,12 @@ class Sidebar extends Component {

togglePanelVisibility(callback = undefined) {
// PANEL IN AND OUT CLASSES
if (window.sidebarOpen) {
window.sidebarOpen = false;
this.setState({ sidebarOpen: false }, () => {
// EMIT A CHANGE IN THE SIDEBAR (IN OR OUT)
window.emitter.emit("sidebarChanged", window.sidebarOpen);
if (callback !== undefined) callback();
});
} else {
window.sidebarOpen = true;
this.setState({ sidebarOpen: true }, () => {
// EMIT A CHANGE IN THE SIDEBAR (IN OR OUT)
window.emitter.emit("sidebarChanged", window.sidebarOpen);
if (callback !== undefined) callback();
});
}
window.sidebarOpen = !window.sidebarOpen;
this.setState({ sidebarOpen: window.sidebarOpen }, () => {
// EMIT A CHANGE IN THE SIDEBAR (IN OR OUT)
window.emitter.emit("sidebarChanged", window.sidebarOpen);
if (callback !== undefined && typeof callback === "function") callback();
});
}

// TOOL AND THEME ITEMS CLICK
Expand All @@ -382,7 +373,7 @@ class Sidebar extends Component {
name={Component.props.name}
helpLink={Component.props.helpLink}
onClose={this.onPanelComponentClose}
onSidebarVisibility={this.togglePanelVisibility}
onSidebarVisibility={() => this.togglePanelVisibility()}
config={Component.props.config}
/>
);
Expand All @@ -408,7 +399,7 @@ class Sidebar extends Component {
name={Component.props.name}
helpLink={Component.props.helpLink}
onClose={this.onPanelComponentClose}
onSidebarVisibility={this.togglePanelVisibility}
onSidebarVisibility={() => this.togglePanelVisibility()}
config={Component.props.config}
/>
);
Expand Down Expand Up @@ -539,7 +530,7 @@ class Sidebar extends Component {
<div
id="sc-sidebar-advanced-tab"
className={this.state.tabClassName}
onClick={this.togglePanelVisibility}
onClick={() => this.togglePanelVisibility()}
>
<img src={require("./images/close-tab.png")} alt="Close Tab" />
</div>
Expand Down