From 9c4d30c16f2ccd8232ecf1b90874956ae5b5dbc6 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 22 Oct 2019 13:36:14 +0200 Subject: [PATCH] MOBILE-3187 myoverview: Fix keyboard flicker on filter --- .../myoverview/addon-block-myoverview.html | 2 +- .../myoverview/components/myoverview/myoverview.ts | 8 +++++++- src/assets/lang/en.json | 2 +- src/components/context-menu/context-menu-item.ts | 2 ++ src/components/context-menu/context-menu-popover.ts | 12 ++++++------ src/components/context-menu/context-menu.ts | 6 +++++- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/addon/block/myoverview/components/myoverview/addon-block-myoverview.html b/src/addon/block/myoverview/components/myoverview/addon-block-myoverview.html index 294a499c4..a7043ba4d 100644 --- a/src/addon/block/myoverview/components/myoverview/addon-block-myoverview.html +++ b/src/addon/block/myoverview/components/myoverview/addon-block-myoverview.html @@ -9,7 +9,7 @@ - + diff --git a/src/addon/block/myoverview/components/myoverview/myoverview.ts b/src/addon/block/myoverview/components/myoverview/myoverview.ts index 2552c597b..e6c807c13 100644 --- a/src/addon/block/myoverview/components/myoverview/myoverview.ts +++ b/src/addon/block/myoverview/components/myoverview/myoverview.ts @@ -334,10 +334,16 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem this.showFilter = !this.showFilter; this.courses.filter = ''; this.filteredCourses = this.courses[this.showFilter ? 'all' : this.selectedFilter]; + } + + /** + * Popover closed after clicking switch filter. + */ + switchFilterClosed(): void { if (this.showFilter) { setTimeout(() => { this.searchbar.setFocus(); - }, 500); + }); } } diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index c5e9e5631..20432a540 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -1316,7 +1316,7 @@ "core.back": "Back", "core.block.blocks": "Blocks", "core.cancel": "Cancel", - "core.cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle 2.4 or later.", + "core.cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle 3.1 or later.", "core.cannotdownloadfiles": "File downloading is disabled. Please contact your site administrator.", "core.captureaudio": "Record audio", "core.capturedimage": "Taken picture.", diff --git a/src/components/context-menu/context-menu-item.ts b/src/components/context-menu/context-menu-item.ts index 9df9e728e..b15a5f82f 100644 --- a/src/components/context-menu/context-menu-item.ts +++ b/src/components/context-menu/context-menu-item.ts @@ -51,12 +51,14 @@ export class CoreContextMenuItemComponent implements OnInit, OnDestroy, OnChange @Input() badgeClass?: number; // A class to set in the badge. @Input() hidden?: boolean; // Whether the item should be hidden. @Output() action?: EventEmitter<() => void>; // Will emit an event when the item clicked. + @Output() onClosed?: EventEmitter<() => void>; // Will emit an event when the popover is closed because the item was clicked. protected hasAction = false; protected destroyed = false; constructor(private ctxtMenu: CoreContextMenuComponent) { this.action = new EventEmitter(); + this.onClosed = new EventEmitter(); } /** diff --git a/src/components/context-menu/context-menu-popover.ts b/src/components/context-menu/context-menu-popover.ts index d96804d6d..6d43c77cf 100644 --- a/src/components/context-menu/context-menu-popover.ts +++ b/src/components/context-menu/context-menu-popover.ts @@ -40,8 +40,8 @@ export class CoreContextMenuPopoverComponent { /** * Close the popover. */ - closeMenu(): void { - this.viewCtrl.dismiss(); + closeMenu(item?: CoreContextMenuItemComponent): void { + this.viewCtrl.dismiss(item); } /** @@ -61,12 +61,12 @@ export class CoreContextMenuPopoverComponent { } if (item.closeOnClick) { - this.closeMenu(); + this.closeMenu(item); } - item.action.emit(this.closeMenu.bind(this)); - } else if (item.href && item.closeOnClick) { - this.closeMenu(); + item.action.emit(this.closeMenu.bind(this, item)); + } else if (item.closeOnClick && (item.href || item.onClosed.observers.length > 0)) { + this.closeMenu(item); } return true; diff --git a/src/components/context-menu/context-menu.ts b/src/components/context-menu/context-menu.ts index ba7fc8a5a..49f7a1e43 100644 --- a/src/components/context-menu/context-menu.ts +++ b/src/components/context-menu/context-menu.ts @@ -180,8 +180,12 @@ export class CoreContextMenuComponent implements OnInit, OnDestroy { const popover = this.popoverCtrl.create(CoreContextMenuPopoverComponent, { title: this.title, items: this.items, id: this.uniqueId, showBackdrop: true }); - popover.onDidDismiss(() => { + popover.onDidDismiss((item: CoreContextMenuItemComponent) => { this.expanded = false; + + if (item) { + item.onClosed.emit(); + } }); popover.present({ ev: event