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

Commit

Permalink
Fix incorrectly rendered editor after change font size on guest portal
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Antonio Scandurra committed Nov 10, 2017
1 parent 2666382 commit d0d6bc6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/guest-portal-binding.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)})
Expand All @@ -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
}
Expand Down

0 comments on commit d0d6bc6

Please sign in to comment.