Wait for next animation frame before measuring when stylesheets change

Fixes #4479
This commit is contained in:
Nathan Sobo 2014-12-09 14:56:20 -07:00
parent 2028045254
commit b386b00bc0
2 changed files with 9 additions and 3 deletions

View File

@ -1908,7 +1908,8 @@ describe "TextEditorComponent", ->
}
""", context: 'atom-text-editor'
nextAnimationFrame()
nextAnimationFrame() # handle stylesheet change event
nextAnimationFrame() # perform requested update
scrollbarCornerNode = componentNode.querySelector('.scrollbar-corner')
expect(verticalScrollbarNode.offsetWidth).toBe 8

View File

@ -664,8 +664,13 @@ TextEditorComponent = React.createClass
onStylesheetsChanged: (styleElement) ->
return unless @performedInitialMeasurement
return unless atom.themes.isInitialLoadComplete()
@refreshScrollbars() if not styleElement.sheet? or @containsScrollbarSelector(styleElement.sheet)
@handleStylingChange()
# This delay prevents the styling from going haywire when stylesheets are
# reloaded in dev mode. It seems like a workaround for a browser bug, but
# not totally sure.
requestAnimationFrame =>
@refreshScrollbars() if not styleElement.sheet? or @containsScrollbarSelector(styleElement.sheet)
@handleStylingChange()
onAllThemesLoaded: ->
@refreshScrollbars()