Skip to content

Commit

Permalink
Delay expansion until the panel collapse is finished because the widt…
Browse files Browse the repository at this point in the history
…h fixer needs to assess the width of the collapsed panel to work properly. Also fixed a typo. Fix #1041.
  • Loading branch information
flekschas committed May 2, 2016
1 parent 8afa0fa commit 2a47d54
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion refinery/ui/source/js/dashboard/controllers/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ function DashboardCtrl (
this.dashboardExpandablePanelService.trigger('lockFullWith');
}
}.bind(this), 0);

this.pubSub.on('collapseFinished', function () {
this.collapsing = false;
}.bind(this));
}

DashboardCtrl.prototype.collectDataSetIds = function () {
Expand Down Expand Up @@ -843,7 +847,7 @@ DashboardCtrl.prototype.expandDataSetPreview = function (
}
}

if (!this.dashboardDataSetPreviewService.previewing) {
function startExpansion () {
if (!this.expandDataSetPanel) {
this.expandDataSetPanel = true;
this.expandedDataSetPanelBorder = true;
Expand All @@ -852,6 +856,19 @@ DashboardCtrl.prototype.expandDataSetPreview = function (
}
this.dashboardDataSetPreviewService.preview(dataSet);
this.dataSetPreview = true;
}

if (!this.dashboardDataSetPreviewService.previewing) {
if (this.collapsing) {
// Panel is currently being collapsed so we need to wait until the
// animation is done because the width fixer needs to capture the
// collapsed panel's width.
this.pubSub.on('collapseFinished', function () {
this.$timeout(startExpansion.bind(this), 0);
}.bind(this), 1);
} else {
startExpansion.apply(this);
}
} else {
if (dataSet.preview) {
this.collapseDataSetPreview(dataSet);
Expand All @@ -878,6 +895,7 @@ DashboardCtrl.prototype.collapseDataSetPreview = function () {

if (!this.repoMode) {
this.expandDataSetPanel = false;
this.collapsing = true;
this.dashboardExpandablePanelService.trigger('collapser');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function refineryExpandablePanel (
.then(function () {
el.removeClass('full-width');
element.removeAttr('style');
pubSub.trigger('collapsFinished');
pubSub.trigger('collapseFinished');
dashboardWidthFixerService.trigger('resetter');
})
.catch(function (e) {
Expand Down

0 comments on commit 2a47d54

Please sign in to comment.