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

Vue 3 - Erroneous properties show in preview when using init-state #736

Open
6 tasks done
hybridwebdev opened this issue Jun 22, 2024 · 1 comment
Open
6 tasks done
Labels
to triage This issue needs to be triaged

Comments

@hybridwebdev
Copy link

hybridwebdev commented Jun 22, 2024

Describe the bug

Consider the following story:

<script setup>
import { ref } from 'vue'
import { logEvent } from 'histoire/client'
import BaseButton from './BaseButton.vue'
let initStateNoBeuno = () => ({
  color: "#f00",
})
let initStateBeuno = () => ({
    props:  {
      color: "#f00"
    }
})
const text = ref('Click me')
</script>

<template>
  <Story >

    <Variant 
        #default='{ state }' :init-state="initStateNoBeuno"
        title='Unexpected properties'
      >
      <BaseButton v-bind="state">
        {{ text }}
      </BaseButton>
    </Variant>
    
    <Variant 
      #default='{ state }'
      :init-state="initStateBeuno"
      title='Nesting works'
    >
      <BaseButton v-bind="state.props">
        {{ text }}
      </BaseButton>
    </Variant>
    
    <template #controls>
      <HstText title="default slot" v-model="text" />
    </template>
  </Story>
</template>

When using the init-state property, either on a story or a variant, unexpected properties show in the dynamic source preview as shown in the screen shot:

image

If you use a nested property, then these properties disappear.

Reproduction

https://stackblitz.com/edit/histoire-vue3-starter-nqsezx?file=src%2FBaseButton.story.vue

System Info

Issue occurs using VUE 3.3 but also in provided sandbox environment.

Used Package Manager

npm

Validations

@hybridwebdev hybridwebdev added the to triage This issue needs to be triaged label Jun 22, 2024
Copy link

stackblitz bot commented Jun 23, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant