From 0fd637c0e94ebdcfb1aa49aedcd7a0b71f3159fb Mon Sep 17 00:00:00 2001 From: Nikhil Date: Wed, 1 Apr 2020 14:22:11 -0700 Subject: [PATCH 1/2] [Notebook]: Error in nextTick: "TypeError: Cannot read property 'focus' of null" #2845 (#2857) --- src/plugins/notebook/components/notebook.vue | 31 +++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/plugins/notebook/components/notebook.vue b/src/plugins/notebook/components/notebook.vue index 7122854e00..eeb73502c3 100644 --- a/src/plugins/notebook/components/notebook.vue +++ b/src/plugins/notebook/components/notebook.vue @@ -80,10 +80,10 @@
{ - const element = this.$el.querySelector(`#${id}`); - element.focus(); - }); - - return id; + this.focusEntryId = id; + this.search = ''; }, orientationChange() { this.formatSidebar(); From 67d53fb62bb95d19bc0ef548c72a847cc30141d1 Mon Sep 17 00:00:00 2001 From: Nikhil Date: Wed, 1 Apr 2020 14:28:52 -0700 Subject: [PATCH 2/2] [Notebook]: When notebook is not default new entry button does not add new entry #2841 (#2855) Co-authored-by: Deep Tailor --- src/plugins/notebook/components/notebook.vue | 29 +++++++++++++------ .../notebook/utils/notebook-storage.js | 13 +-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/plugins/notebook/components/notebook.vue b/src/plugins/notebook/components/notebook.vue index eeb73502c3..34004072c5 100644 --- a/src/plugins/notebook/components/notebook.vue +++ b/src/plugins/notebook/components/notebook.vue @@ -216,6 +216,20 @@ export default { this.updateSection({ sections }); this.throttledSearchItem(''); }, + createNotebookStorageObject() { + const notebookMeta = { + name: this.internalDomainObject.name, + identifier: this.internalDomainObject.identifier + }; + const page = this.getSelectedPage(); + const section = this.getSelectedSection(); + + return { + notebookMeta, + section, + page + } + }, dragOver(event) { event.preventDefault(); event.dataTransfer.dropEffect = "copy"; @@ -379,12 +393,9 @@ export default { this.updateSection({ sections }); }, newEntry(embed = null) { - const selectedSection = this.getSelectedSection(); - const selectedPage = this.getSelectedPage(); this.search = ''; - - this.updateDefaultNotebook(selectedSection, selectedPage); - const notebookStorage = getDefaultNotebook(); + const notebookStorage = this.createNotebookStorageObject(); + this.updateDefaultNotebook(notebookStorage); const id = addNotebookEntry(this.openmct, this.internalDomainObject, notebookStorage, embed); this.focusEntryId = id; this.search = ''; @@ -417,13 +428,13 @@ export default { toggleNav() { this.showNav = !this.showNav; }, - async updateDefaultNotebook(selectedSection, selectedPage) { + async updateDefaultNotebook(notebookStorage) { const defaultNotebookObject = await this.getDefaultNotebookObject(); this.removeDefaultClass(defaultNotebookObject); - setDefaultNotebook(this.internalDomainObject, selectedSection, selectedPage); + setDefaultNotebook(notebookStorage); this.addDefaultClass(); - this.defaultSectionId = selectedSection.id; - this.defaultPageId = selectedPage.id; + this.defaultSectionId = notebookStorage.section.id; + this.defaultPageId = notebookStorage.page.id; }, updateDefaultNotebookPage(pages, id) { if (!id) { diff --git a/src/plugins/notebook/utils/notebook-storage.js b/src/plugins/notebook/utils/notebook-storage.js index 37a71317ad..a84581a877 100644 --- a/src/plugins/notebook/utils/notebook-storage.js +++ b/src/plugins/notebook/utils/notebook-storage.js @@ -10,18 +10,7 @@ export function getDefaultNotebook() { return JSON.parse(notebookStorage); } -export function setDefaultNotebook(domainObject, section, page) { - const notebookMeta = { - name: domainObject.name, - identifier: domainObject.identifier - }; - - const notebookStorage = { - notebookMeta, - section, - page - } - +export function setDefaultNotebook(notebookStorage) { window.localStorage.setItem(NOTEBOOK_LOCAL_STORAGE, JSON.stringify(notebookStorage)); }