|
1 | 1 | import React, {Fragment, useRef, useState} from 'react'; |
2 | 2 |
|
| 3 | +import {useUniqId} from '@gravity-ui/uikit'; |
| 4 | + |
3 | 5 | import AnimateBlock from '../../components/AnimateBlock/AnimateBlock'; |
4 | 6 | import ButtonTabs, {ButtonTabsItemProps} from '../../components/ButtonTabs/ButtonTabs'; |
5 | 7 | import FullscreenImage from '../../components/FullscreenImage/FullscreenImage'; |
@@ -36,13 +38,19 @@ export const TabsBlock = ({ |
36 | 38 | const ref = useRef<HTMLDivElement>(null); |
37 | 39 | const mediaWidth = ref?.current?.offsetWidth; |
38 | 40 | const mediaHeight = mediaWidth && getHeight(mediaWidth); |
| 41 | + const captionId = useUniqId(); |
39 | 42 |
|
40 | 43 | let imageProps; |
41 | 44 |
|
42 | 45 | if (activeTabData) { |
43 | 46 | const themedImage = getThemedValue(activeTabData.image, theme); |
44 | 47 |
|
45 | 48 | imageProps = themedImage && getMediaImage(themedImage); |
| 49 | + if (activeTabData.caption && imageProps) { |
| 50 | + Object.assign(imageProps, { |
| 51 | + 'aria-describedby': captionId, |
| 52 | + }); |
| 53 | + } |
46 | 54 | } |
47 | 55 |
|
48 | 56 | const showMedia = Boolean(activeTabData?.media || imageProps); |
@@ -99,7 +107,11 @@ export const TabsBlock = ({ |
99 | 107 | <FullscreenImage {...imageProps} imageClassName={b('image')} /> |
100 | 108 | </Fragment> |
101 | 109 | )} |
102 | | - {activeTabData?.caption && <p className={b('caption')}>{activeTabData.caption}</p>} |
| 110 | + {activeTabData?.caption && ( |
| 111 | + <p className={b('caption')} id={captionId}> |
| 112 | + {activeTabData.caption} |
| 113 | + </p> |
| 114 | + )} |
103 | 115 | </Col> |
104 | 116 | ); |
105 | 117 |
|
|
0 commit comments