@@ -19,6 +19,7 @@ import { omitSpacingProps, pickSpacingProps } from '../flex/utils'
1919import ItemIcon from './ItemIcon'
2020import ItemTitle from './ItemTitle'
2121import { createSkeletonClass } from '../skeleton/SkeletonHelper'
22+ import Context from '../../shared/Context'
2223
2324export type ItemAccordionIconPosition = 'left' | 'right'
2425
@@ -141,6 +142,7 @@ function AccordionHeader(props: AccordionHeaderProps) {
141142 title,
142143 } = useContext ( ItemAccordionContext )
143144
145+ const context = useContext ( Context )
144146 const inheritedSkeleton = useContext ( ListContext ) ?. skeleton
145147 const isInactive = pending || disabled
146148
@@ -166,7 +168,7 @@ function AccordionHeader(props: AccordionHeaderProps) {
166168 [ handleClick ]
167169 )
168170
169- return (
171+ const content = (
170172 < FlexItem
171173 className = { classnames (
172174 'dnb-list__item__accordion__header' ,
@@ -191,20 +193,33 @@ function AccordionHeader(props: AccordionHeaderProps) {
191193 { chevronPosition === 'right' && < ChevronIcon /> }
192194 </ FlexItem >
193195 )
196+
197+ if ( inheritedSkeleton ) {
198+ return (
199+ < Context . Provider
200+ value = { { ...context , skeleton : inheritedSkeleton } }
201+ >
202+ { content }
203+ </ Context . Provider >
204+ )
205+ }
206+
207+ return content
194208}
195209ItemAccordion . Header = AccordionHeader
196210AccordionHeader . _supportsSpacingProps = true
197211
198212function AccordionContent ( props : ItemContentProps ) {
199213 const { className, children, ...rest } = props
214+ const context = useContext ( Context )
200215 const { openState, accordionId, keepInDOM } = useContext (
201216 ItemAccordionContext
202217 )
203218 const inheritedSkeleton = useContext ( ListContext ) ?. skeleton
204219
205220 const spacingProps = pickSpacingProps ( rest )
206221
207- return (
222+ const content = (
208223 < FlexItem
209224 className = { classnames (
210225 'dnb-list__item__accordion__content' ,
@@ -223,6 +238,18 @@ function AccordionContent(props: ItemContentProps) {
223238 </ HeightAnimation >
224239 </ FlexItem >
225240 )
241+
242+ if ( inheritedSkeleton ) {
243+ return (
244+ < Context . Provider
245+ value = { { ...context , skeleton : inheritedSkeleton } }
246+ >
247+ { content }
248+ </ Context . Provider >
249+ )
250+ }
251+
252+ return content
226253}
227254ItemAccordion . Content = AccordionContent
228255AccordionContent . _supportsSpacingProps = true
0 commit comments