histoire-dev / histoire

⚡ Fast and beautiful interactive component playgrounds, powered by Vite
https://histoire.dev
MIT License
3.21k stars 192 forks source link

"Initial state" controls empty even when prop values for the component got defined #188

Closed awacode21 closed 2 years ago

awacode21 commented 2 years ago

Describe the bug

The initial state controls of a component are always empty, even though there got prop values defined for a component. It doesn't matter if i set every single prop on its own for a component or if i use v-bind with an object containing the props. in each case the initial state controls are empty.

On reproduction with the button example the button gets the initial state to be red with count 2. But the controls are empty. I would expect that the controls get the values which are defined for the component.

Bildschirmfoto 2022-07-20 um 11 31 23 Bildschirmfoto 2022-07-20 um 11 32 31

Reproduction

https://stackblitz.com/edit/histoire-vue3-empty-controls-on-initial-state?file=src%2FBaseButton.story.vue

System Info

System:
    OS: macOS 12.1
    CPU: (8) x64 Apple M1
    Memory: 23.70 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Chrome: 103.0.5060.114
    Firefox: 102.0.1
    Safari: 15.2
  npmPackages:
    @vitejs/plugin-vue: ^2.3.3 => 2.3.3
    histoire: ^0.7.9 => 0.7.9
    vite: ^2.9.13 => 2.9.13

Used Package Manager

npm

Validations

awacode21 commented 2 years ago

Might be related somehow to: https://github.com/histoire-dev/histoire/issues/164

Akryum commented 2 years ago

Looks like it's working for me: image

Maybe you mean the Auto Props Controls which are just overrides so they are inactive by default.

awacode21 commented 2 years ago

But then i don't understand the auto props controls. What are they useful for?

Akryum commented 2 years ago

They allow you to override any prop value even if there are no controls authored for it.

awacode21 commented 2 years ago

so you always need to define your own controls to reflect props initial state? sounds like auto props are useless. Because if you nevertheless need to define your own controls to reflect with initial state then you have always double controls which do the same. This confuses me a bit and i think also the "reader" because he don't know which of the controls to use. Is there a config option to switch off the auto props display?

Akryum commented 2 years ago

We could display the default values of props in the auto props controls, but that's separate from your original issue. Maybe you can open a feature request?

Is there a config option to switch off the auto props display?

https://histoire.dev/reference/vue3/story.html#autopropsdisabled

awacode21 commented 2 years ago

We could display the default values of props in the auto props controls, but that's separate from your original issue. Maybe you can open a feature request?

Is there a config option to switch off the auto props display?

https://histoire.dev/reference/vue3/story.html#autopropsdisabled

thank you very much for clarification and the docs link. i will open a feature request for displaying default values of props in the auto props controls