storybook icon indicating copy to clipboard operation
storybook copied to clipboard

[Bug]: Strange vue3 code snippet behavior with "icon" based properties in alpha

Open KevinCarnaille2 opened this issue 1 year ago • 6 comments

Describe the bug

While migrating to 7.1.0-alpha-40, in a vue3-vite SB project, I'm facing a strange issue when my components contain properties with the string "icon"

Instead of simply displaying the property and its string value, it renders a kind of function :

export const Default = {
    args: {
        icon: 'I am the icon property',
        iconSize: 'small',
        color: 'blue'
    }
}

And the code snippet result :

<template>
  <MyCmp icon="()=>({})" icon-size="()=>({})" color="blue" />
</template>

You can preview the issue with the github repository below, I reproduced the issue pretty easily :) Thanks !

To Reproduce

https://github.com/KevinCarnaille2/sb-vue3-sourcecode-issue

System

Binaries:
    Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.1/bin/npm
Browsers:
    Chrome: 114.0.5735.106
npmPackages:
    @storybook/addon-essentials: ^7.1.0-alpha.40 => 7.1.0-alpha.40 
    @storybook/addon-interactions: ^7.1.0-alpha.40 => 7.1.0-alpha.40 
    @storybook/addon-links: ^7.1.0-alpha.40 => 7.1.0-alpha.40 
    @storybook/blocks: ^7.1.0-alpha.40 => 7.1.0-alpha.40 
    @storybook/testing-library: ^0.2.0-next.1 => 0.2.0 
    @storybook/vue3: ^7.1.0-alpha.40 => 7.1.0-alpha.40 
    @storybook/vue3-vite: ^7.1.0-alpha.40 => 7.1.0-alpha.40

Additional context

You can have a look at the "ButtonIcon" story in the docs

No response

### Tasks
- [ ] Vue3
- [ ] args

KevinCarnaille2 avatar Jun 27 '23 07:06 KevinCarnaille2

same things You cannot use any props with on inside check https://github.com/storybookjs/storybook/blame/next/code/renderers/vue3/src/docs/utils.ts#L23

timonbandit avatar Oct 10 '23 15:10 timonbandit

@chakAs3 @kasperpeulen looks like we are incorrectly treating everything with /^on/ as event handler

vanessayuenn avatar Jan 04 '24 14:01 vanessayuenn

@timonbandit using props with on will be treated as an event handler and be considered as action, ideally avoid attributes starting with 'on' or override this in actions property in your preview

Image

chakAs3 avatar Jan 13 '24 10:01 chakAs3

@chakAs3 icon does not match the regex ^on[A-Z]. so either the problem is elsewhere (my guess) or the argTypeRegex code is buggy (also possible).

shilman avatar Jan 26 '24 03:01 shilman

@chakAs3 icon does not match the regex ^on[A-Z]. so either the problem is elsewhere (my guess) or the argTypeRegex code is buggy (also possible).

funny the argTypeRegex is buggy because there is 'on' in 'icon' i will see what we can do to fix this

chakAs3 avatar Jan 27 '24 18:01 chakAs3

I believe this is fixed in https://github.com/storybookjs/storybook/pull/25219 (https://github.com/storybookjs/storybook/releases/tag/v8.0.0-alpha.15)

tfoxkiu avatar Jan 28 '24 04:01 tfoxkiu

Indeed this should be fixed already by https://github.com/storybookjs/storybook/pull/25219. I am closing this issue for now. But please let me know if it isn't fixed.

vanessayuenn avatar Jan 29 '24 11:01 vanessayuenn