Skip to content

Commit

Permalink
Only render/remove submenus when menu is rendered or rendering
Browse files Browse the repository at this point in the history
Added the 'or rendering' part. Otherwise rendering of the submenus will
fail when called through a render method (of the menu itself) method
instead of a menu action.

Menu: remove unnecessary fix for a problem that was caused by not
rendering the submenus correctly.

Change-Id: I98e12c0d286478eab774672873f8fa4b1e98d627
Signed-off-by: Ralf Muri <ralf.muri@bsi-software.com>
Reviewed-on: https://git.eclipse.org/r/160191
Tested-by: CI Bot
Reviewed-by: Roger Stebler <roger.stebler@bsi-software.com>
  • Loading branch information
rmuri committed Apr 2, 2020
1 parent 260d018 commit c32f909
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ scout.ContextMenuPopup.prototype._installScrollbars = function() {
};

scout.ContextMenuPopup.prototype.removeSubMenuItems = function(parentMenu, animated) {
if (!this.rendered) {
if (!this.rendered && !this.rendering) {
return;
}
if (this.bodyAnimating) {
Expand Down Expand Up @@ -160,7 +160,7 @@ scout.ContextMenuPopup.prototype.renderSubMenuItems = function(parentMenu, menus
};
return;
}
if (!this.rendered) {
if (!this.rendered && !this.rendering) {
return;
}
if (this.bodyAnimating) {
Expand Down
27 changes: 11 additions & 16 deletions org.eclipse.scout.rt.ui.html/src/main/js/scout/menu/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,17 @@ scout.Menu.prototype._removeSubMenuItems = function(parentMenu) {
scout.Menu.prototype._renderSubMenuItems = function(parentMenu, menus) {
if (this.parent instanceof scout.ContextMenuPopup) {
this.parent.renderSubMenuItems(parentMenu, menus, true);
// only attach close handler when menus are really rendered. This is usually not the case on startup or reload.
if (menus.filter(function(m) {
return m.rendered;
}).length > 0) {
var closeHandler = function(event) {
parentMenu.setSelected(false);
}.bind(this);
var propertyChangeHandler = function(event) {
if (event.propertyName === 'selected' && event.newValue === false) {
this.parent.off('close', closeHandler);
parentMenu.off('propertyChange', propertyChangeHandler);
}
}.bind(this);
this.parent.on('close', closeHandler);
parentMenu.on('propertyChange', propertyChangeHandler);
}
var closeHandler = function(event) {
parentMenu.setSelected(false);
}.bind(this);
var propertyChangeHandler = function(event) {
if (event.propertyName === 'selected' && event.newValue === false) {
this.parent.off('close', closeHandler);
parentMenu.off('propertyChange', propertyChangeHandler);
}
}.bind(this);
this.parent.on('close', closeHandler);
parentMenu.on('propertyChange', propertyChangeHandler);
} else if (this.parent instanceof scout.Menu) {
this.parent._renderSubMenuItems(parentMenu, menus);
}
Expand Down

0 comments on commit c32f909

Please sign in to comment.