storybook icon indicating copy to clipboard operation
storybook copied to clipboard

Vue ArgsTable missing prop if slot with same name

Open fallemand opened this issue 4 years ago • 7 comments

Describe the bug If I define a prop and a slot with the same name, ArgsTable only displays the slot

To Reproduce Create a vue component with a prop and slot using the same name. See component example below.

Screenshots Using the same name image

Changing the prop name image

Code snippets

<template>
  <span>
    <!-- @slot Pass a custom title -->
    <slot name="title">
      {{ title }}
    </slot>
  </span>
</template>

<script>
import Vue from 'vue';

export default {
  name: 'Title',
  props: {
    /** Title */
    title: {
      type: String,
      default: null,
    },
  },
};
</script>

System

Environment Info:

  System:
    OS: macOS 10.15.6
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
  Binaries:
    Node: 12.18.0 - ~/.nvm/versions/node/v12.18.0/bin/node
    npm: 6.14.4 - ~/.nvm/versions/node/v12.18.0/bin/npm
  Browsers:
    Chrome: 86.0.4240.80
    Firefox: 79.0
    Safari: 13.1.2
  npmPackages:
    @storybook/addon-a11y: ^6.0.26 => 6.0.26 
    @storybook/addon-essentials: ^6.0.26 => 6.0.26 
    @storybook/vue: 6.0.26 => 6.0.26 

fallemand avatar Oct 21 '20 13:10 fallemand

I am getting this also. Slot and prop with the same name is a valid case in vue.

braddialpad avatar Dec 08 '20 18:12 braddialpad

Seems this is the same issue as this https://github.com/storybookjs/storybook/issues/12224

braddialpad avatar Dec 08 '20 19:12 braddialpad

Any news about this bug ?

gaetansenn avatar Jan 20 '21 23:01 gaetansenn

I think I prefer grouping props and slots, perhaps in the second parameter passed to the template.

lee-chase avatar Apr 03 '21 14:04 lee-chase

It will be awesome to see it happening in 6.3. This has big implications for most vue design systems, since usually slots and props have the same name.

fallemand avatar May 27 '21 14:05 fallemand

Hacky workaround: image This gets both the fields prop and fields slot to show in the args table. Unfortunately it seems the slot fields is bound to the actual prop, so maybe you'd need to overwrite both in your story to get it to work in the argstable. For mine it's an array of objects so not worth getting it to work.

update, that does work: image

atflick avatar Aug 17 '22 16:08 atflick

I think it's better to write this way, but the best solution is to modify the source code, otherwise you won't be able to enjoy the benefits of automatic generation.

const argTypes = {
  "slot:fields": {
    name: "fields",
    table: {
      category: "slots",
    },
  },
  fields: {
    table: {
      category: "props",
    },
  },
};

cxzx150133 avatar Sep 19 '22 06:09 cxzx150133

Version 6.5.13

I too have encountered this issue, wondering why my props are missing from the table. I'd prefer not having to maintain storybook manually to keep it in sync with my components.

blowsie avatar Nov 11 '22 18:11 blowsie

Sadly, still an issue in storybook/@storybook/vue3 version 7.0.12

wouterkroes avatar Aug 11 '23 09:08 wouterkroes

Issue exist if you have described css part and slot with the same name.

nnaydenow avatar Oct 20 '23 12:10 nnaydenow

Seems to still be an issue with Storybook v8.

patrickcate avatar Apr 29 '24 02:04 patrickcate