SketchAPI icon indicating copy to clipboard operation
SketchAPI copied to clipboard

Text Layer style.textColor reads previous color on Undo

Open davebaraka opened this issue 5 years ago • 0 comments

When changing the textColor through the api and then 'undoing' (cmd + z), Sketch API will read the color before 'undoing' while the Sketch UI shows the correct previous color.

For example, if you run the following script on a project with just a text layer with a textColor = '#ffffff' (white)

var document = require('sketch/dom').getSelectedDocument()
document.selectedPage.layers.forEach(layer => {
  layer.style.textColor = "#000000"
  console.log(layer.style.textColor)
})

The textColor will appropriately change to black, '#000000'. Though, if you do an undo (cmd + z), to change the textColor back to white, sketch will show the appropriate white color on the layer and in the inspector, but the api will read black when running the following script

var document = require('sketch/dom').getSelectedDocument()
document.selectedPage.layers.forEach(layer => {
  console.log(layer.style.textColor)
})

This does not seem to happen on fills or borders...

davebaraka avatar Jul 10 '20 17:07 davebaraka