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

Fix broken editor rendering after changing font size on guest portals #185

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

as-cii
Copy link
Contributor

@as-cii as-cii commented Nov 10, 2017

Fixes #174

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.

This is admittedly something that we should have better support for in core, but this workaround should be an okay stopgap measure.

/cc: @nathansobo @jasonrudolph

@as-cii as-cii changed the title Fix incorrectly rendered editor after change font size on guest portal Fix incorrectly rendered editor after changing font size on guest portal Nov 10, 2017
@as-cii as-cii changed the title Fix incorrectly rendered editor after changing font size on guest portal Fix incorrectly rendered editors after changing font size on guest portals Nov 10, 2017
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.
@as-cii as-cii force-pushed the fix-incorrectly-rendered-editors branch from d0d6bc6 to 89787fc Compare November 10, 2017 15:21
@as-cii as-cii changed the title Fix incorrectly rendered editors after changing font size on guest portals Fix broken editor rendering after changing font size on guest portals Nov 10, 2017
@nathansobo
Copy link
Contributor

Does the TextEditorRegistry support this curretly?

@as-cii
Copy link
Contributor Author

as-cii commented Nov 10, 2017

I don't think so. Notifications of style updates come straight from AtomEnvironment by calling a static method on TextEditorComponent named didUpdateStyles. That method consults a Set of attached components and, for each of them, calls the didUpdateStyles instance method.

I guess one way of fixing that would be to call didUpdateStyles on every created TextEditorComponent, making sure we delete those components whose editor has been destroyed.

@nathansobo
Copy link
Contributor

I guess one way of fixing that would be to call didUpdateStyles on every created TextEditorComponent, making sure we delete those components whose editor has been destroyed.

Ah, except that could lead to leaks of editors that package authors forget to explicitly destroy. For a solution in core, what if we maintained a static field on the constructor with an incrementing style update counter. When an editor gets reattached, we could compare its count with the constructors and force an update if we see that we're out of date.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants