Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code snippets not working correctly when prop and slot have same name (7.1.0-alpha-42)(Vue 3) #23470

Open
rstainsby opened this issue Jul 16, 2023 · 2 comments · May be fixed by #24432
Open

Comments

@rstainsby
Copy link

rstainsby commented Jul 16, 2023

The Issue

This pull request, whilst solving some issues, seems to have included a bug that causes code snippets to generate incorrect code if a prop has the same key as a slot.

Example

For example, I have the following story:

export const IconOnly: Story = {
  ...Default,
  args: {
    icon: 'pi pi-check'
  }
}

which outputs this code snippet:

<template>
  <Button icon="()=>({})" />
</template>

where, in previous versions, it output:

<template>
  <Button icon="pi pi-check"/>
</template>

Project Setup

I am using Storybook (7.1.0-alpha-42) with Vue 3 (3.3.4) and PrimeVue component library (3.29.2).

This is happening with the use of the Button component which has an 'icon' prop and an 'icon' slot. If I were to take a guess I'd think that the slot and prop having the same name is causing the problem.

Here's the API for the component https://primevue.org/button/.

Happy to send across full file's if it makes things easier.

Originally posted by @rstainsby in #22518 (comment)

@rstainsby rstainsby changed the title Code snippets not working correctly when prop and slot have same name (7.1.0-alpha-42) Code snippets not working correctly when prop and slot have same name (7.1.0-alpha-42)(Vue 3) Jul 16, 2023
@valentinpalkovic
Copy link
Contributor

cc @chakAs3

@chakAs3
Copy link
Contributor

chakAs3 commented Jul 19, 2023

@rstainsby yes i'm aware of this issue, this limitation comes from the initial CSF API Design that may work for some renderer like React because React uses children to pass the slots, but may create a conflict. for vue as vue separate props and slots.
means. in vue you can have same name for slots and props without any issue but storybook args = { ... props , ...slots } which show clearly the limitation we have here.

I'm working on RFC that proposes :

args = { ...props, options:{ stots:..slotsArgs, globals:..config} } 

any. thoughts @valentinpalkovic ?
@shilman sure you are aware of this, we already discussed it.

timonbandit added a commit to timonbandit/storybook that referenced this issue Oct 11, 2023
@timonbandit timonbandit linked a pull request Oct 11, 2023 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants