@@ -15,6 +15,7 @@ import type { ButtonDomRef } from '../../webComponents/Button/index.js';
1515import { Button } from '../../webComponents/Button/index.js' ;
1616import type { ToggleButtonDomRef , ToggleButtonPropTypes } from '../../webComponents/ToggleButton/index.js' ;
1717import { ToggleButton } from '../../webComponents/ToggleButton/index.js' ;
18+ import type { ObjectPagePropTypes } from '../ObjectPage/types/index.js' ;
1819import { classNames , styleData } from './ObjectPageAnchorBar.module.css.js' ;
1920
2021const _buttonBaseMinWidth = `${ cssVarVersionInfoPrefix } button_base_min_width` ;
@@ -53,11 +54,7 @@ interface ObjectPageAnchorBarPropTypes extends CommonProps {
5354 /**
5455 * Defines internally used accessibility properties/attributes.
5556 */
56- accessibilityAttributes ?: {
57- objectPageAnchorBar ?: {
58- role ?: string ;
59- } ;
60- } ;
57+ accessibilityAttributes ?: ObjectPagePropTypes [ 'accessibilityAttributes' ] [ 'objectPageAnchorBar' ] ;
6158 /**
6259 * Fired when the `headerContent` changes its pinned state.
6360 */
@@ -114,14 +111,18 @@ const ObjectPageAnchorBar = forwardRef<HTMLElement, ObjectPageAnchorBarPropTypes
114111 const showHideHeaderBtn = showHideHeaderBtnRef . current ;
115112 void customElements . whenDefined ( tagName ) . then ( ( ) => {
116113 if ( showHideHeaderBtn ) {
114+ const expanded =
115+ accessibilityAttributes ?. expandButton && Object . hasOwn ( accessibilityAttributes . expandButton , 'expanded' )
116+ ? accessibilityAttributes . expandButton . expanded
117+ : ! ! headerContentVisible ;
117118 showHideHeaderBtn . accessibilityAttributes = {
118- expanded : ! ! headerContentVisible ,
119+ expanded,
119120 hasPopup : undefined ,
120121 controls : undefined ,
121122 } ;
122123 }
123124 } ) ;
124- } , [ ! ! headerContentVisible ] ) ;
125+ } , [ accessibilityAttributes ?. expandButton ?. expanded , ! ! headerContentVisible ] ) ;
125126
126127 const onToggleHeaderButtonClick = ( e ) => {
127128 onToggleHeaderContentVisibility ( enrichEventWithDetails ( e , { visible : ! headerContentVisible } ) ) ;
@@ -131,7 +132,7 @@ const ObjectPageAnchorBar = forwardRef<HTMLElement, ObjectPageAnchorBarPropTypes
131132 < section
132133 data-component-name = "ObjectPageAnchorBar"
133134 style = { style }
134- role = { accessibilityAttributes ?. objectPageAnchorBar ?. role }
135+ role = { accessibilityAttributes ?. role }
135136 className = { ! hidePinButton ? classNames . container : null }
136137 ref = { ref }
137138 >
@@ -149,7 +150,10 @@ const ObjectPageAnchorBar = forwardRef<HTMLElement, ObjectPageAnchorBarPropTypes
149150 onMouseOver = { onHoverToggleButton }
150151 onMouseLeave = { onHoverToggleButton }
151152 tooltip = { i18nBundle . getText ( ! headerContentVisible ? EXPAND_HEADER : COLLAPSE_HEADER ) }
152- accessibleName = { i18nBundle . getText ( ! headerContentVisible ? EXPAND_HEADER : COLLAPSE_HEADER ) }
153+ accessibleName = {
154+ accessibilityAttributes ?. expandButton ?. accessibleName ??
155+ i18nBundle . getText ( ! headerContentVisible ? EXPAND_HEADER : COLLAPSE_HEADER )
156+ }
153157 data-component-name = "ObjectPageAnchorBarExpandBtn"
154158 />
155159 { shouldRenderHeaderPinnableButton && (
0 commit comments