MOBILE-2319 contextmenu: Don't merge menus from different tabs
parent
d29712258a
commit
d8be7efbc6
|
@ -12,12 +12,13 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Component, Input, OnInit, OnDestroy, ElementRef } from '@angular/core';
|
||||
import { Component, Input, OnInit, OnDestroy, ElementRef, Optional } from '@angular/core';
|
||||
import { PopoverController } from 'ionic-angular';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||
import { CoreContextMenuItemComponent } from './context-menu-item';
|
||||
import { CoreContextMenuPopoverComponent } from './context-menu-popover';
|
||||
import { CoreTabComponent } from '@components/tabs/tab';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
/**
|
||||
|
@ -40,7 +41,7 @@ export class CoreContextMenuComponent implements OnInit, OnDestroy {
|
|||
protected parentContextMenu: CoreContextMenuComponent;
|
||||
|
||||
constructor(private translate: TranslateService, private popoverCtrl: PopoverController, elementRef: ElementRef,
|
||||
private domUtils: CoreDomUtilsProvider) {
|
||||
private domUtils: CoreDomUtilsProvider, @Optional() public coreTab: CoreTabComponent) {
|
||||
// Create the stream and subscribe to it. We ignore successive changes during 250ms.
|
||||
this.itemsChangedStream = new Subject<void>();
|
||||
this.itemsChangedStream.auditTime(250).subscribe(() => {
|
||||
|
|
|
@ -134,10 +134,12 @@ export class CoreNavBarButtonsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
// Both containers have a context menu. Merge them to prevent having 2 menus at the same time.
|
||||
const mainContextMenuInstance = this.domUtils.getInstanceByElement(mainContextMenu),
|
||||
secondaryContextMenuInstance = this.domUtils.getInstanceByElement(secondaryContextMenu);
|
||||
const mainContextMenuInstance: CoreContextMenuComponent = this.domUtils.getInstanceByElement(mainContextMenu),
|
||||
secondaryContextMenuInstance: CoreContextMenuComponent = this.domUtils.getInstanceByElement(secondaryContextMenu);
|
||||
|
||||
if (mainContextMenuInstance && secondaryContextMenuInstance) {
|
||||
// Check that both context menus belong to the same core-tab. We shouldn't merge menus from different tabs.
|
||||
if (mainContextMenuInstance && secondaryContextMenuInstance &&
|
||||
mainContextMenuInstance.coreTab === secondaryContextMenuInstance.coreTab) {
|
||||
this.mergedContextMenu = secondaryContextMenuInstance;
|
||||
|
||||
this.mergedContextMenu.mergeContextMenus(mainContextMenuInstance);
|
||||
|
|
Loading…
Reference in New Issue