Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to add button type to CAccordionButton when used through CAccordionHeader? #252

Answered by mrholek
PoeppingT asked this question in Q&A
Discussion options

Hi all,

I'm using the CAccordion construct as part of a layered form, very useful! I have just one problem -- because the CAccordionButton created by the CAccordionHeader component doesn't have type=button applied, my Formik form things I'm submitting the form and doing validations before I want.

Looking at the code, it looks like the CAccordionButton could support this if used directly:

 return (
 <button
 className={_className}
 {...rest}
 aria-expanded={!visible}
 onClick={() => setVisible(!visible)}
 ref={ref}
 >
 {children}
 </button>
 )

but the CAccordionHeader does not apply any such type (via the rest prop):

 return (
 <div className={_className} {...rest} ref={ref}>
 <CAccordionButton>{children}</CAccordionButton>
 </div>
 )

Is there a way to pass this type configuration through the CAccordionHeader to still make use of the ref and collapse functionality?

You must be logged in to vote

@PoeppingT it's a bug, I will fix it next release.

Replies: 1 comment

Comment options

@PoeppingT it's a bug, I will fix it next release.

You must be logged in to vote
0 replies
Answer selected by PoeppingT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /