sketch-hq / SketchAPI

The JavaScript plugin library embedded in Sketch
https://developer.sketch.com/reference/api
MIT License
842 stars 126 forks source link

PR: on feature/43561 #892

Closed opsGavin closed 2 years ago

opsGavin commented 2 years ago

Connect sketch-hq/sketch#43561

Created by bo pr.

opsGavin commented 2 years ago

These changes have been introduced because we are enabling the symbol click-through flag inHouse. There are two changes of note.

The first is that under clickthrough we have changed how availableOverrides are calculated. Previously, this relied on the symbol instance being invalidated. We no longer do this and instead we now rely on the detached versions of the symbols. However, detaching is done on a background thread and may not have completed by the time the overrides are requested, so to get around that we need to call ensureDetachHasUpdated() which will block until the current detach completes.

The second change with clickthrough is that, unlike before, when an override is selected the symbol instance isn't considered selected. Selecting overrides is now much more like selecting a normal layer. I've update the override selection tests to reflect this, and also updated the selection code to use the newer Selection and SelectionItem objects (selectedOverrides is deprecated and will go away soon).