From a743cdc5c6962c4d13456890bf8b338efe6604b1 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Thu, 3 May 2018 18:22:13 -0500 Subject: [PATCH] Fixes issue where deleting one editor may clear the current editor session --- .../javascripts/app/controllers/editor.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/app/controllers/editor.js b/app/assets/javascripts/app/controllers/editor.js index 668460c3b..488d4f3d8 100644 --- a/app/assets/javascripts/app/controllers/editor.js +++ b/app/assets/javascripts/app/controllers/editor.js @@ -443,12 +443,21 @@ angular.module('app') // Autocomplete Tags this.tagsComponent = component.active ? component : null; } else if(component.area == "editor-editor") { - // Editor - if(component.active && this.note && (component.isExplicitlyEnabledForItem(this.note) || component.isDefaultEditor())) { - this.selectedEditor = component; + // An editor is already active, ensure the potential replacement is explicitely enabled for this item + if(this.selectedEditor) { + if(component.isExplicitlyEnabledForItem(this.note)) { + this.selectedEditor = component; + } } else { - this.selectedEditor = null; + // If no selected editor, let's see if the incoming one is a candidate + if(component.active && this.note && (component.isExplicitlyEnabledForItem(this.note) || component.isDefaultEditor())) { + this.selectedEditor = component; + } else { + // Not a candidate, and no selected editor. Disable the current editor by setting selectedEditor to null + this.selectedEditor = null; + } } + } else if(component.area == "editor-stack") { this.reloadComponentContext(); }