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(a11y): signpost close aria label update and allow user to config aria label #1624

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .storybook/stories/signpost/signpost.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default {
args: {
// inputs
clrPosition: 'right-middle',
clrSignpostCloseAriaLabel: 'Info Close',
// story helpers
content: 'Hello World!',
},
Expand All @@ -52,7 +53,7 @@ export default {
const template = `
<div style="padding: 250px; text-align: center">
<clr-signpost>
<clr-signpost-content [clrPosition]="clrPosition">
<clr-signpost-content [clrPosition]="clrPosition" [clrSignpostCloseAriaLabel]="clrSignpostCloseAriaLabel">
{{ content }}
</clr-signpost-content>
</clr-signpost>
Expand Down
4 changes: 3 additions & 1 deletion projects/angular/clarity.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3633,9 +3633,11 @@ export class ClrSignpostContent extends AbstractPopover implements OnDestroy {
get position(): string;
set position(position: string);
// (undocumented)
signpostCloseAriaLabel: string;
// (undocumented)
signpostContentId: string;
// (undocumented)
static ɵcmp: i0.ɵɵComponentDeclaration<ClrSignpostContent, "clr-signpost-content", never, { "position": "clrPosition"; }, {}, never, ["*"], false, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<ClrSignpostContent, "clr-signpost-content", never, { "signpostCloseAriaLabel": "clrSignpostCloseAriaLabel"; "position": "clrPosition"; }, {}, never, ["*"], false, never>;
// (undocumented)
static ɵfac: i0.ɵɵFactoryDeclaration<ClrSignpostContent, [null, { optional: true; }, null, null, null, null, null]>;
}
Expand Down
4 changes: 3 additions & 1 deletion projects/angular/src/popover/signpost/signpost-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const POSITIONS: string[] = [
<div class="signpost-content-header">
<button
type="button"
[attr.aria-label]="commonStrings.keys.signpostClose"
[attr.aria-label]="signpostCloseAriaLabel || commonStrings.keys.signpostClose"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[attr.aria-label]="signpostCloseAriaLabel || commonStrings.keys.signpostClose"
[attr.aria-label]="signpostCloseAriaLabel"

Copy link
Member

Choose a reason for hiding this comment

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

The current implementation is better so that we default to the common string if a falsy value is bound to the input. This is a pattern we use in several places, and I think this one should be the same.

Copy link
Contributor Author

@spadidapelli spadidapelli Dec 4, 2024

Choose a reason for hiding this comment

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

@dtsanevmw They want to custom aria label with name of trigger element, so current implementation is better and we are using same pattern in other places also.

class="signpost-action close"
(click)="close()"
[attr.aria-controls]="signpostContentId"
Expand All @@ -56,6 +56,8 @@ const POSITIONS: string[] = [
host: { '[class.signpost-content]': 'true', '[id]': 'signpostContentId' },
})
export class ClrSignpostContent extends AbstractPopover implements OnDestroy {
@Input('clrSignpostCloseAriaLabel') signpostCloseAriaLabel: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just use it as a default value?

Suggested change
@Input('clrSignpostCloseAriaLabel') signpostCloseAriaLabel: string;
@Input('clrSignpostCloseAriaLabel') signpostCloseAriaLabel = this.commonStrings.keys.signpostClose;

Copy link
Member

Choose a reason for hiding this comment

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

See my other comment for why defaulting to the common string in the template is better (and consistent with existing code). #1624 (comment)


signpostContentId = uniqueIdFactory();

private document: Document;
Expand Down
2 changes: 1 addition & 1 deletion projects/angular/src/utils/i18n/common-strings.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const commonStringsDefault: ClrCommonStrings = {
showColumnsMenuDescription: 'Show or hide columns menu',
allColumnsSelected: 'All columns selected',
signpostToggle: 'Signpost Toggle',
signpostClose: 'Signpost Close',
signpostClose: 'Close',
loading: 'Loading',
// Datagrid
detailPaneStart: 'Start of row details',
Expand Down
Loading