You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Since Storybook 8.0 component, default, named and dynamic slots for autogenerated code examples no longer render. Assuming that this was once a feature that has since been removed, it really doesn't make much sense.
For example, given the following component:
<script setup lang="ts">
importErrorCollectionfrom"./NpErrorCollection.vue"importNpLabelfrom"@/components/form/NpLabel.vue"importtype { NpFormFieldPropsasProps } from"@/types/components/np-form"const props =defineProps<Props>()defineSlots<{/** * Default slot for the label content. * This is where the main label text should be placed.*/ default?():any;/** * Slot for additional suffix content after the label. * This could include icons, additional text, etc.*/ suffix?():any;/** * Slot for hint content below the label. * This is useful for providing additional information or instructions.*/ hint?():any;/** * Slot for the input element. * This slot is used to render the form input field element or component.*/ input?():any; }>()const hasErrors = () =>!!props.errors.length
</script>
<template>
<div:data-testid="testId ? `${testId}` : undefined">
<NpLabel:test-id="testId ? `${testId}.label` : undefined":for="$props.for":is-disabled="isDisabled":has-error="hasErrors()":is-sr-only="isSrOnly"
>
<slotname="default" />
<templatev-if="$slots.suffix"
#suffix
>
<slotname="suffix" />
</template>
<templatev-if="$slots.hint"
#hint
>
<slotname="hint" />
</template>
</NpLabel>
<divv-if="$slots.input":data-testid="testId ? `${testId}.input` : undefined"class="mt-2"
>
<slotname="input" />
</div>
<ErrorCollectionv-if="hasErrors()":test-id="testId ? `${testId}.errors` : undefined":errors="errors"class="mt-2"
/>
</div>
</template>
And the following story:
constmeta={title: "Components / Form / NpFormField",component: NpFormField,subcomponents: { NpInputText },parameters: {docs: {description: {component: `A simple field component using \`NpStandardLabel\` and \`NpErrorCollection\` to be used with form inputs.`,},},},render: (args)=>({components: { NpFormField, NpInputText },setup(){return{ args }},template: ` <NpFormField v-bind="args"> <template #default>Label text</template> <template #suffix> (Optional) </template> <template #hint> Description or hint </template> <template #input> <NpInputText id="input-id" testId="test-input-id" :hasError="args.errors.length > 0" :disabled="!!args.isDisabled" /> </template> </NpFormField>`,}),}satisfiesMeta<typeofNpFormField>exportdefaultmetatypeStory=StoryObj<typeofmeta>exportconstWithLabelAndHintAndSuffixAndTextInput: Story={args: {for: "input-id",errors: []asstring[],},play: async({ canvasElement })=>{constcanvas=within(canvasElement)// check labelawaitexpect(canvas.getByText("Label text")).toBeDefined()// check suffixawaitexpect(canvas.getByText("(Optional)")).toBeDefined()// check hintawaitexpect(canvas.getByText("Description or hint")).toBeDefined()// check interaction with input in slotconsttextInput=canvas.getByTestId("test-input-id")awaitexpect(textInput).toBeVisible()awaituserEvent.type(textInput,"I am using interaction tests")awaitexpect(textInput).toHaveValue("I am using interaction tests")},}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Is your feature request related to a problem? Please describe.
Since Storybook 8.0 component, default, named and dynamic slots for autogenerated code examples no longer render. Assuming that this was once a feature that has since been removed, it really doesn't make much sense.
For example, given the following component:
And the following story:
The generated code example is:
Describe the solution you'd like
Code examples rendered default, named and dynamic slot content
Describe alternatives you've considered
No response
Are you able to assist to bring the feature to reality?
no
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions