react-components icon indicating copy to clipboard operation
react-components copied to clipboard

TS Lint Error on title prop in Accordion component

Open pedoch opened this issue 1 year ago • 2 comments

When a ReactNode or JSXElement is passed to the title prop in the Accordion sections array, it throws an error.

Types of property 'title' are incompatible.
        Type 'ReactNode' is not assignable to type 'string | undefined'.
          Type 'null' is not assignable to type 'string | undefined'.

However, the documentation says it accepts a ReactNode for further title customisation.

pedoch avatar Oct 18 '24 11:10 pedoch

Weird, the AccordionSection does accept ReactNode:

https://github.com/canonical/react-components/blob/ab70886f9350584c219318636e919dc25a8bc8e6/src/components/Accordion/AccordionSection/AccordionSection.tsx#L28-L31

bartaz avatar Nov 14 '24 13:11 bartaz

And we do have example where nodes are passed to the title:

https://github.com/canonical/react-components/blob/ab70886f9350584c219318636e919dc25a8bc8e6/src/components/Accordion/Accordion.stories.tsx#L195-L204

Could there be something else that is wrong/different? Would you he able to try our storybook example in your env to see if that works?

bartaz avatar Nov 14 '24 13:11 bartaz

Hey @bartaz, I completely forgot about this. The problem may have been that our Vanilla version was outdated (I'm not sure). But checking where we implemented this, I don't see the error anymore (we've updated Vanilla several times since I created this issue).

Thanks for the reply! Apologies for not following up on this. I'll be closing this now.

pedoch avatar Jun 03 '25 09:06 pedoch