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

[Bug]: key prop missing on generated source code #24581

Open
brynshanahan opened this issue Oct 26, 2023 · 3 comments
Open

[Bug]: key prop missing on generated source code #24581

brynshanahan opened this issue Oct 26, 2023 · 3 comments

Comments

@brynshanahan
Copy link

Describe the bug

Children are missing their key prop in the Canvas DocBlock. The key is an important part of the component's api

To Reproduce

// Accordion.stories.tsx
export default {
    title: 'Components/Accordion',
    component: Accordion,
    id: 'next-accordion',
}

export const ExpandByDefault = {
    component: Accordion,
    args: {
        defaultExpandedKeys: ['accordion2'],
        children: [
            <AccordionItem key='accordion1' title='Accordion 1'>
                <p>Accordion 1.</p>

                <p>More content.</p>
            </AccordionItem>,
            <AccordionItem key='accordion2' title='Accordion 2'>
                <p>Accordion 2.</p>

                <p>More content.</p>
            </AccordionItem>,
        ],
    },
}
// Accordion.mdx
<Canvas of={stories.ExpandedByDefault} />
image

System

System:
    OS: macOS 13.3.1
    CPU: (10) x64 Apple M1 Pro
    Shell: 3.2.57 - /bin/sh
  Binaries:
    Node: 16.19.0 - /usr/local/bin/node
    Yarn: 3.4.1 - /usr/local/bin/yarn <----- active
    npm: 8.19.3 - /usr/local/bin/npm
  Browsers:
    Chrome: 118.0.5993.88
    Safari: 16.4

Additional context

No response

@shilman
Copy link
Member

shilman commented Jan 11, 2024

We're generating the source snippets with https://github.com/algolia/react-element-to-jsx-string#readme. My guess is that it's either a bug there, or the key information is simply unavailable once the code is rendered into JSX elements. More investigation needed!

@suneel00
Copy link

Hi @brynshanahan
I attempted to utilize the eventKey property for the React-Bootstrap AccordionItem instead of the key property.

image

image

@DanielHara
Copy link

DanielHara commented Jan 30, 2024

Hi there!
Yes, I'm also experiencing this issue and it looks like the bug comes from algolia/react-element-to-jsx-string#301, and I've opened a PR there to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants