MOBILE-3281 glossary: Open first item if not selected not in the list

main
Pau Ferrer Ocaña 2020-03-02 10:53:08 +01:00
parent 7dee04764a
commit 088dbcd821
1 changed files with 15 additions and 0 deletions

View File

@ -189,6 +189,21 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
Array.prototype.push.apply(this.entries, result.entries);
} else {
this.entries = result.entries;
if (this.splitviewCtrl.isOn()) {
// Load the first entry.
if (this.entries.length > 0) {
const found = this.selectedEntry && this.entries.some((entry) => entry.id == this.selectedEntry);
// The current selected entry is not found in the current list, open first item.
if (!found) {
this.openEntry(this.entries[0].id);
}
} else {
this.selectedEntry = null;
this.splitviewCtrl.emptyDetails();
}
}
}
this.canLoadMore = this.entries.length < result.count;
}).catch((error) => {