Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit d0d6bc6

Browse files
author
Antonio Scandurra
committed
Fix incorrectly rendered editor after change font size on guest portal
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.
1 parent 2666382 commit d0d6bc6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/guest-portal-binding.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ class GuestPortalBinding {
155155
this.newActivePaneItem = newActivePaneItem
156156

157157
if (this.activePaneItem) {
158+
this.ensurePaneItemStylesAreUpToDate(newActivePaneItem)
159+
158160
const pane = this.workspace.paneForItem(this.activePaneItem)
159161
const index = pane.getItems().indexOf(this.activePaneItem)
160162
pane.addItem(newActivePaneItem, {index, moved: this.addedPaneItems.has(newActivePaneItem)})
@@ -170,6 +172,18 @@ class GuestPortalBinding {
170172
this.newActivePaneItem = null
171173
}
172174

175+
ensurePaneItemStylesAreUpToDate (paneItem) {
176+
// When editor styles change, Atom notifies only editor components that
177+
// are attached to the DOM at the moment of the change. Thus, if the
178+
// element we are about to add had already been rendered, we will
179+
// preemptively clear all its styling information to ensure it will render
180+
// correctly even if some styles changed while it was not attached to the
181+
// DOM.
182+
if (this.addedPaneItems.has(paneItem) && paneItem instanceof TextEditor) {
183+
paneItem.component.didUpdateStyles()
184+
}
185+
}
186+
173187
getActivePaneItem () {
174188
return this.newActivePaneItem ? this.newActivePaneItem : this.activePaneItem
175189
}

0 commit comments

Comments
 (0)