-
Notifications
You must be signed in to change notification settings - Fork 203
[IRN-6372] [BpkBottomSheet] - aria title read on Android TalkBack #4175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ import BpkCloseButton from '../../bpk-component-close-button'; | |
| import BpkLink from '../../bpk-component-link'; | ||
| import BpkNavigationBar from '../../bpk-component-navigation-bar'; | ||
| import { TEXT_STYLES } from '../../bpk-component-text/src/BpkText'; | ||
| import BpkVisuallyHidden from '../../bpk-component-visually-hidden'; | ||
| import { BpkDialogWrapper, cssModules } from '../../bpk-react-utils'; | ||
|
|
||
| import STYLES from './BpkBottomSheet.module.scss'; | ||
|
|
@@ -74,13 +75,13 @@ interface CommonProps { | |
| export type Props = CommonProps & ({ ariaLabelledby: string } | { ariaLabel: string; }); | ||
|
|
||
| const getContentStyles = (paddingStyles: PaddingStyles): string => { | ||
| const { | ||
| const { | ||
| bottom = PADDING_TYPE.lg, | ||
| end, | ||
| start = PADDING_TYPE.lg, | ||
| top = PADDING_TYPE.none | ||
| end, | ||
| start = PADDING_TYPE.lg, | ||
| top = PADDING_TYPE.none | ||
| } = paddingStyles; | ||
|
|
||
| const classNames = ['bpk-bottom-sheet--content']; | ||
|
|
||
| // Add padding classes for each side if not 'none' | ||
|
|
@@ -155,6 +156,7 @@ const BpkBottomSheet = ({ | |
| ); | ||
|
|
||
| const headingId = `bpk-bottom-sheet-heading-${id}`; | ||
| const headingIsHidden = !title && 'ariaLabel' in ariaProps; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Detect if we're in the situation where we only have a heading for ScreenReader purposes to describe the dialog (no visual title) |
||
| const dialogClassName = getClassName( | ||
| 'bpk-bottom-sheet', | ||
| wide && 'bpk-bottom-sheet--wide', | ||
|
|
@@ -185,7 +187,7 @@ const BpkBottomSheet = ({ | |
| <> | ||
| <header className={getClassName('bpk-bottom-sheet--header-wrapper')}> | ||
| <BpkNavigationBar | ||
| id={headingId} | ||
| id={headingIsHidden ? `bpk-bottom-sheet-title-hidden-${id}` : headingId} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we adding a Screen Reader heading below using |
||
| title={title} | ||
| titleTextStyle={TEXT_STYLES.label1} | ||
| titleTagName={title ? 'h2' : 'span'} | ||
|
|
@@ -199,6 +201,12 @@ const BpkBottomSheet = ({ | |
| ) : null | ||
| } | ||
| /> | ||
| {/* non-visible header element required for Android TalkBack to announce ariaLabel when no title provided on open BottomSheet */} | ||
| {headingIsHidden && ( | ||
| <BpkVisuallyHidden as="h2"> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same heading level as NavBar normally uses for visual Bottom Sheet title (when it has one) Tested on Android with TalkBack via "No Header" story and now we do get the aria title announced on open while still maintaining focus on the close button. ✅ |
||
| <span id={`bpk-bottom-sheet-title-hidden-${id}`}>{ariaProps.ariaLabel}</span> | ||
| </BpkVisuallyHidden> | ||
| )} | ||
| </header> | ||
| <div className={contentStyle}>{children}</div> | ||
| </> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No change here - linter seems to have hoovered up some old trailing spaces