From 088dbcd8216e5118e3031a69a86f8c98023e6d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Mon, 2 Mar 2020 10:53:08 +0100 Subject: [PATCH] MOBILE-3281 glossary: Open first item if not selected not in the list --- src/addon/mod/glossary/components/index/index.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/addon/mod/glossary/components/index/index.ts b/src/addon/mod/glossary/components/index/index.ts index a2016e96b..c12178ba2 100644 --- a/src/addon/mod/glossary/components/index/index.ts +++ b/src/addon/mod/glossary/components/index/index.ts @@ -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) => {