figma / plugin-typings

Typings for the Figma Plugin API
MIT License
195 stars 45 forks source link

Missing support for ComponentNode documentationLinks to be cleared out (null value) #33

Closed madebyfabian closed 3 years ago

madebyfabian commented 3 years ago

Hello there. I was using the new https://www.figma.com/plugin-docs/api/properties/ComponentNode-documentationlinks/ property, and as there is told, it is currently only supported to add one link. That's fine. But what's really missing here is that "clearing" out the field.

I built a plugin ("Bunch Description Change") where users can do different things with their' component descriptions. I am currently adding support for the "documentationLinks" property, but other than on the "description", where I can clear it (just like in the UI), with the "documentationLinks", I cannot clear it. This may cause confusion for the user of my plugin.

When I try to mutate it by saying component.documentationLinks = null, it throws me an error saying that it's not allowed. But also when trying this: component.documentationLinks = [{ uri: null }] (so exactly like in the docs) it also throws me an error saying that the type "null" is not allowed and a "string" type is required.

It would be really helpful if you could just allow setting an empty string/null so the field can clear up, just like you're possible to do in the UI. Thanks!

jlai-figma commented 3 years ago

@madebyfabian - can you try setting component.documentationLinks = [] ?

madebyfabian commented 3 years ago

This does work! @jlai-figma Thank you! Somehow I didn't thought about it.

jlai-figma commented 3 years ago

We can add this to the documentation, thank you for raising this!

madebyfabian commented 3 years ago

@jlai-figma this would be great, yes! Thank you!