Template API V2: `findLayers` doesn't work with `path`
Hi everyone,
I can't get findLayers() to work with the path prop, even though the docs say that it should work.
I'm using Template API V2.
instance.findLayers((child) => true) works fine
instance.findConnectedInstances((child) => true, { path: ['parentLayerName'], }) also works fine
but just calling instance.findLayers((child) => true, { path: ['parentLayerName'] })
or even instance.findLayers((child) => true, { path: [] })
immediately gets me an error, even before using the result in any way:
Am I doing something wrong, or is there a bug in findLayers, or maybe it's described incorrectly in the docs and doesn't actually accept path?
After some digging, it seems that text objects just don't have a path property, only instances have it. Which means that nor findLayers, neither findText can work with the path parameter.
Here's an example of a text object from a raw figma object:
{
"name": "title",
"type": "TEXT",
"textContent": "Card Title"
}
And here's an example of an instance:
{
"properties": {
...
},
"name": "Info",
"children": [],
"type": "INSTANCE",
"symbolId": "52262:239602",
"path": [
"Card.Header",
"Flex (heading)",
"Card.Title",
"Info icon with tooltip (Informer)"
],
"__properties__": {}
}