11import React , { useContext } from 'react' ;
22
33import { AnalyticsEventsProp , useAnalytics } from '@gravity-ui/page-constructor' ;
4- import { Icon } from '@gravity-ui/uikit' ;
4+ import { Icon , useUniqId } from '@gravity-ui/uikit' ;
55
66import { LikesContext } from '../../../contexts/LikesContext' ;
77import { Save as SaveIcon } from '../../../icons/Save' ;
@@ -11,6 +11,7 @@ import {block} from '../../../utils/cn';
1111import { postLikeStatus } from '../../../utils/common' ;
1212
1313import '../PostInfo.scss' ;
14+ import { Keyset , i18n } from '../../../i18n' ;
1415
1516const ICON_SIZE = 16 ;
1617
@@ -52,6 +53,9 @@ export const Save = ({
5253 const handleAnalytics = useAnalytics ( DefaultEventNames . SaveButton ) ;
5354 const isLikeable = Boolean ( toggleLike ) ;
5455
56+ const titleElementId = useUniqId ( ) ;
57+ const isNumericTitle = typeof title === 'number' ;
58+
5559 return (
5660 < button
5761 className = { b ( 'item' , { size, save : true } ) }
@@ -76,6 +80,9 @@ export const Save = ({
7680 handleAnalytics ( analyticsEvents ) ;
7781 } }
7882 data-qa = { qa }
83+ aria-pressed = { hasUserLike }
84+ aria-label = { isNumericTitle ? i18n ( Keyset . Save ) : undefined }
85+ aria-describedby = { isNumericTitle ? titleElementId : undefined }
7986 >
8087 < div className = { b ( 'content' , { cursor : isLikeable , theme} ) } >
8188 < span className = { b ( 'icon' ) } >
@@ -85,7 +92,9 @@ export const Save = ({
8592 className = { b ( { filled : Boolean ( hasUserLike ) } ) }
8693 />
8794 </ span >
88- < span className = { b ( 'title' , { cursor : isLikeable } ) } > { title } </ span >
95+ < span id = { titleElementId } className = { b ( 'title' , { cursor : isLikeable } ) } >
96+ { title }
97+ </ span >
8998 </ div >
9099 </ button >
91100 ) ;
0 commit comments