From 89787fc019ebf6b54f0ee0ab8b2fbcff9a42656f Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 10 Nov 2017 16:10:55 +0100 Subject: [PATCH] Fix broken editor rendering after changing font size on guest portals When editor styles change, Atom notifies only editor components that are attached to the DOM at the moment of the change. Thus, if the element we are about to add had already been rendered, we will preemptively clear all its styling information to ensure it will render correctly even if some styles changed while it was not attached to the DOM. --- lib/guest-portal-binding.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/guest-portal-binding.js b/lib/guest-portal-binding.js index 7a008ee7..3fa00968 100644 --- a/lib/guest-portal-binding.js +++ b/lib/guest-portal-binding.js @@ -155,6 +155,8 @@ class GuestPortalBinding { this.newActivePaneItem = newActivePaneItem if (this.activePaneItem) { + this.ensurePaneItemStylesAreUpToDate(newActivePaneItem) + const pane = this.workspace.paneForItem(this.activePaneItem) const index = pane.getItems().indexOf(this.activePaneItem) pane.addItem(newActivePaneItem, {index, moved: this.addedPaneItems.has(newActivePaneItem)}) @@ -170,6 +172,18 @@ class GuestPortalBinding { this.newActivePaneItem = null } + ensurePaneItemStylesAreUpToDate (paneItem) { + // When editor styles change, Atom notifies only editor components that + // are attached to the DOM at the moment of the change. Thus, if the + // element we are about to add had already been rendered, we will + // preemptively clear all its styling information to ensure it will render + // correctly even if some styles changed while it was not attached to the + // DOM. + if (this.addedPaneItems.has(paneItem) && paneItem instanceof TextEditor) { + paneItem.component.didUpdateStyles() + } + } + getActivePaneItem () { return this.newActivePaneItem ? this.newActivePaneItem : this.activePaneItem }