File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,6 +71,25 @@ describe('EuiFlyout', () => {
7171 ) . toBeFalsy ( ) ;
7272 } ) ;
7373
74+ it ( 'allows setting custom aria-describedby attributes' , ( ) => {
75+ const { getByTestSubject } = render (
76+ < >
77+ < EuiFlyout
78+ onClose = { ( ) => { } }
79+ aria-describedby = "custom-test-id"
80+ data-test-subj = "flyout"
81+ />
82+ < div id = "custom-test-id" hidden >
83+ This flyout does X, Y, and Z
84+ </ div >
85+ </ >
86+ ) ;
87+ expect ( getByTestSubject ( 'flyout' ) ) . toHaveAttribute (
88+ 'aria-describedby' ,
89+ 'generated-id custom-test-id'
90+ ) ;
91+ } ) ;
92+
7493 describe ( 'props' , ( ) => {
7594 test ( 'hideCloseButton' , ( ) => {
7695 const component = mount ( < EuiFlyout onClose = { ( ) => { } } hideCloseButton /> ) ;
Original file line number Diff line number Diff line change @@ -183,6 +183,7 @@ export const EuiFlyout = forwardRef(
183183 pushMinBreakpoint = 'l' ,
184184 focusTrapProps : _focusTrapProps = { } ,
185185 includeFixedHeadersInFocusTrap = true ,
186+ 'aria-describedby' : _ariaDescribedBy ,
186187 ...rest
187188 } : EuiFlyoutProps < T > ,
188189 ref :
@@ -349,6 +350,7 @@ export const EuiFlyout = forwardRef(
349350 */
350351 const hasOverlayMask = ownFocus && ! isPushed ;
351352 const descriptionId = useGeneratedHtmlId ( ) ;
353+ const ariaDescribedBy = classnames ( descriptionId , _ariaDescribedBy ) ;
352354
353355 const screenReaderDescription = (
354356 < EuiScreenReaderOnly >
@@ -416,7 +418,7 @@ export const EuiFlyout = forwardRef(
416418 { ...( rest as ComponentPropsWithRef < T > ) }
417419 role = { ! isPushed ? 'dialog' : rest . role }
418420 tabIndex = { ! isPushed ? 0 : rest . tabIndex }
419- aria-describedby = { ! isPushed ? descriptionId : undefined }
421+ aria-describedby = { ! isPushed ? ariaDescribedBy : _ariaDescribedBy }
420422 data-autofocus = { ! isPushed || undefined }
421423 >
422424 { ! isPushed && screenReaderDescription }
You can’t perform that action at this time.
0 commit comments