Skip to content

Commit

Permalink
[Web UI] Quick fix for FireFox resize event bug (#2475)
Browse files Browse the repository at this point in the history
Event objects in FireFox appear to get garbage collected sooner than in other browsers. Prevent unintended null reference at `event.currentTarget` by not passing the event object into the async debounce handler.
  • Loading branch information
10xjs authored Dec 3, 2018
1 parent 2562559 commit 4b18f6d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased

### Fixed
- Fixed a web-ui bug causing the app to crash on window resize in FireFox

### [5.0.0] - 2018-11-30

### Added
Expand Down
10 changes: 7 additions & 3 deletions dashboard/src/components/partials/ToolbarMenu/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ToolbarMenu extends React.PureComponent {
};

componentWillUnmount() {
this.handleWindowResize.clear();
this.updateButtonsWidth.clear();
}

handleOverflowButtonResize = rect => {
Expand All @@ -92,8 +92,12 @@ class ToolbarMenu extends React.PureComponent {
});
};

handleWindowResize = debounce(ev => {
const newWidth = ev.currentTarget.innerWidth;
handleWindowResize = event => {
this.updateButtonsWidth(event.currentTarget);
};

updateButtonsWidth = debounce(currentTarget => {
const newWidth = currentTarget.innerWidth;
const oldWidth = this.windowWidth || 0;

// If the window grew in size and the toolbar menu isn't configured to fill
Expand Down

0 comments on commit 4b18f6d

Please sign in to comment.