field-plugin icon indicating copy to clipboard operation
field-plugin copied to clipboard

"actions.selectAsset()" only returns the filename but not things like Alt Text or Asset ID

Open MilanFox opened this issue 8 months ago • 3 comments

Describe the bug First of all, thanks for making Storyblok such a modular product. The recent changes in the Field Plugins are much appreciated!

I am in need of building a rather customized version of the native asset selector, for which I would need the whole asset object, but "selectAsset()" only returns an Object that includes the filename for me, but not the rest of the Asset Metadata, like Alt Texts, Focus Points, etc.:

{
  "filename": "https://www.a.storyblok.com/some/file/path.png"
}

I can reproduce the behaviour from a fresh new instance of a Plugin that is created with "npx @storyblok/field-plugin-cli@latest add --dir \"./packages\" --structure monorepo" (this is a monorepo project), so I am not linking a minimal repro here - in case this would help I am of course adding it.

I am using the Vue 3 template in case this makes a difference.

To Reproduce Steps to reproduce the behavior:

  1. Create a new Component, following the documentation
  2. In the Example-Component "AssetSelector.vue", add a console log of the content of "asset.value" after line 10, where it waits for the asset selector promise.
  3. Select any asset (in my case I've tried it with images only)
  4. Console.log shows an "incomplete" asset object with only a filename.

Expected behavior I would have expected the asset object to include the same data, that the native asset selector returns. At a minimum the asset ID so I can get the missing Info via the management API.

For reference, the Asset Object, I would have expected: https://www.storyblok.com/docs/api/management/core-resources/assets/the-asset-object

Desktop (Just in case this makes a difference):

  • OS: OS X 14.5
  • Browser: Chrome 126.0.6478.114
  • Using @storyblok/field-plugin & @storyblok/field-plugin-cli @latest, which is currently 1.1.2, I think

Additional context I did a very quick test with the old <sb-asset-selector> and I feel like this meta component does the same thing, but I might be wrong here.

MilanFox avatar Jun 24 '24 16:06 MilanFox