MOBILE-3187 myoverview: Fix keyboard flicker on filter

main
Dani Palou 2019-10-22 13:36:14 +02:00
parent 4c03c0174a
commit 9c4d30c16f
6 changed files with 22 additions and 10 deletions

View File

@ -9,7 +9,7 @@
<ion-spinner *ngIf="!prefetchCoursesData[selectedFilter].icon || prefetchCoursesData[selectedFilter].icon == 'spinner'"></ion-spinner>
</div>
<core-context-menu item-end>
<core-context-menu-item *ngIf="loaded && showFilterSwitchButton()" [priority]="1000" [content]="'core.courses.filtermycourses' | translate" (action)="switchFilter()" iconAction="funnel"></core-context-menu-item>
<core-context-menu-item *ngIf="loaded && showFilterSwitchButton()" [priority]="1000" [content]="'core.courses.filtermycourses' | translate" (action)="switchFilter()" iconAction="funnel" (onClosed)="switchFilterClosed()"></core-context-menu-item>
<core-context-menu-item *ngIf="loaded && showSortFilter" [priority]="900" content="{{('core.sortby' | translate) + ' ' + ('addon.block_myoverview.title' | translate)}}" (action)="switchSort('fullname')" [iconAction]="sort == 'fullname' ? 'radio-button-on' : 'radio-button-off'"></core-context-menu-item>
<core-context-menu-item *ngIf="loaded && showSortFilter" [priority]="800" content="{{('core.sortby' | translate) + ' ' + ('addon.block_myoverview.lastaccessed' | translate)}}" (action)="switchSort('lastaccess')" [iconAction]="sort == 'lastaccess' ? 'radio-button-on' : 'radio-button-off'"></core-context-menu-item>
</core-context-menu>

View File

@ -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);
});
}
}

View File

@ -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.",

View File

@ -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();
}
/**

View File

@ -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;

View File

@ -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