Skip to content
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

fix(material/dialog): dialog name on mac only using aria-label #29264

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

essjay05
Copy link
Contributor

Fixes bug with Angular Components Dialog component on Mac whether using Chrome or Firefox the screenreader does not read the dialog name/title unless it is using an aria-label. Updates the dialog-content-directives to read/apply the aria- labelledby and aria-describedby values if they exist.

Fixes b/274674581

@jelbourn jelbourn added the dev-app preview When applied, previews of the dev-app are deployed to Firebase label Jun 14, 2024
Copy link

github-actions bot commented Jun 14, 2024

Deployed dev-app for c17c4f0 to: https://ng-dev-previews-comp--pr-angular-components-29264-dev-rjpcttjr.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

@essjay05 essjay05 force-pushed the dialog-name-title-fix branch 5 times, most recently from 4d12a2a to 9a62391 Compare June 24, 2024 20:17
@essjay05 essjay05 force-pushed the dialog-name-title-fix branch 2 times, most recently from 478e548 to 2342929 Compare June 27, 2024 00:19
@angular-robot angular-robot bot added the area: docs Related to the documentation label Jun 27, 2024
@angular-robot angular-robot bot removed the area: docs Related to the documentation label Jun 27, 2024
@essjay05 essjay05 marked this pull request as ready for review June 27, 2024 22:58
@essjay05 essjay05 requested a review from a team as a code owner June 27, 2024 22:58
@essjay05 essjay05 requested review from amysorto and mmalerba and removed request for a team June 27, 2024 22:58
@@ -68,7 +68,7 @@ export function throwDialogContentAlreadyAttachedError() {
'[attr.aria-modal]': '_config.ariaModal',
'[attr.aria-labelledby]': '_config.ariaLabel ? null : _ariaLabelledByQueue[0]',
'[attr.aria-label]': '_config.ariaLabel',
'[attr.aria-describedby]': '_config.ariaDescribedBy || null',
'[attr.aria-describedby]': '_config.ariaLabel ? null : _ariaDescribedByQueue[0]',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are multiple, shouldn't they all be part of the aria-describedby, not just the first one?

@@ -117,6 +126,59 @@ export class MatDialogContainer extends CdkDialogContainer<MatDialogConfig> impl
);
}

/** Get userAgent to check for useragent operating system */
private _getUserPlatform = (): string => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a cdk/platform package that we use for this type of thing

@@ -93,6 +97,11 @@ export class MatDialogContainer extends CdkDialogContainer<MatDialogConfig> impl
: 0;
/** Current timer for dialog animations. */
private _animationTimer: ReturnType<typeof setTimeout> | null = null;
/** Platform Observer */
// private _userAgentSubscription = Subscription.EMPTY;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out code

};

/** Get Dialog name from aria attributes */
private _getDialogName = (): string => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method seems pretty crazy and I would hope we can find a better way to accomplish this.

Also just in general, its bad practice to have a method called getXYZ that you rely on for its side effects rather than its return value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the input, Miles! Revising now.

Fixes bug with Angular Components Dialog component on Mac
whether using Chrome or Firefox the screenreader does not
read the dialog name/title unless it is using an aria-label.
Updates the dialog-content-directives to read/apply the aria-
labelledby and aria-describedby values if they exist.

Fixes b/274674581
Fixes issue with Angular Components Dialog component where VoiceOver
does not read the dialog name if the dialog is supposed to be read by
aria-labelledby or aria-describedby attributes. Updates dialog-container.ts
so that the aria-labelledby or aria-described by value (if any) is used
as an aria-label value.

Fixes b/274674581
Fixes Angular Components Dialog component where the dialog name is
not read by VoiceOver/screenreader on macOS chrome & firefox
browsers. Attempts to retrieve any id associated with aria-labelledby
or aria-describedby and taking the innerHTML or the aria-label of that
element and applying that value to the dialog's aria-label.

Fixes b/274674581
…ome or firefox

Fixes bug in Angular Components Dialog component where the aria-labelledby
and aria-describedby values are not being read by Chrome or Firefox when
using a mac. This checks if there is an html attribute of aria-labelledby
or aria-describedby and grabs the innerText or aria-label value and uses
that value as the aria-label for the dialog only on mac using chrome or
firefox.

Fixes b/274674581
…ome and firefox

Fixes Angular Components Dialog component where the mac screenreader is not
reading the associated aria-labelledby id value as the dialog name/title.
Fixes logic checking for macos so that the function_getDialogName() gets
called when the value of the arialabelledby id element gets inserted into
the aria-label value.

Fixes b/274674581
Cleans up fix for Angular Component Dialog component's fix to update
the dialog aria-label if the user's OS is a mac since mac using a
chrome or firefox browser the screenreader does NOT read the dialog
name if the value is portrayed by aria-labelledby or aria-describedby.
Cleaned up console logs and unused attributes.

Fixes b/274674581
…ome or firefox

Cleans up unused variables and comments.

Fixes b/274674581
…firefox

Removes test console logs from CDK dialog-container.ts.

Fixes b/274674581
…sing chrome or firefox

Updates fix for Angular Components Dialog issue where the dialog name
is not being read by the screenreader when specifically using macos
(and potentially ios) screenreader when using chrome or firefox
browsers. Removes unused commented out code and includes ios as part
of the logic to call  _getDialogName().

Fixes b/274674581
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-app preview When applied, previews of the dev-app are deployed to Firebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants