-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(material/sort): add description input for sort-header #23633
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
Conversation
@@ -176,6 +199,9 @@ export class MatSortHeader extends _MatSortHeaderBase | |||
{toState: this._isSorted() ? 'active' : this._arrowDirection}); | |||
|
|||
this._sort.register(this); | |||
|
|||
this._sortButton = this._elementRef.nativeElement.querySelector('[role="button"]')!; |
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.
Should we use a ViewChild
query to get the button instead of querying directly?
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.
IMO I don't see the point of using @ViewChild
to query for native DOM elements (vs. directives or injectables)
|
||
// If _sortButton is undefined, the component hasn't been initialized yet so there's | ||
// nothing to update in the DOM. | ||
if (this._sortButton) { |
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.
Do we also need to check that the description is defined/isn't an empty string here?
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.
AriaDescriber
already checks the presence of the message internally
f2e49a2
to
3bb13ed
Compare
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.
LGTM, but the CI is failing.
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.
seems reasonable to me 👍
src/components-examples/material/table/table-sorting/table-sorting-example.ts
Show resolved
Hide resolved
Adds a description input for mat-sort-header so that developers can provide an accessible description (using AriaDescirber under the hood). Additionally update the accessibility section for the sort header's documentation with guidance on providing an accessible experience. I decided to use this approach instead of expanding `MatSortHeaderIntl` because the message developers would want to set here depends on several bits of information, including: * Whether the column is currently sorted * The sort direction * Whether users can clear sorting (configured on `MatSort`) * The name of the column (not the ID) Accounting for all of these factors would have made the intl formatting too complicated. This does have the negative consequence of needing to set a description for every header. However, users can add a custom directive to set the description in a consistent way if they have an application with many tables.
Adds a description input for mat-sort-header so that developers can provide an accessible description (using AriaDescirber under the hood). Additionally update the accessibility section for the sort header's documentation with guidance on providing an accessible experience. I decided to use this approach instead of expanding `MatSortHeaderIntl` because the message developers would want to set here depends on several bits of information, including: * Whether the column is currently sorted * The sort direction * Whether users can clear sorting (configured on `MatSort`) * The name of the column (not the ID) Accounting for all of these factors would have made the intl formatting too complicated. This does have the negative consequence of needing to set a description for every header. However, users can add a custom directive to set the description in a consistent way if they have an application with many tables. (cherry picked from commit ecd54f4)
Adds a description input for mat-sort-header so that developers can provide an accessible description (using AriaDescirber under the hood). Additionally update the accessibility section for the sort header's documentation with guidance on providing an accessible experience. I decided to use this approach instead of expanding `MatSortHeaderIntl` because the message developers would want to set here depends on several bits of information, including: * Whether the column is currently sorted * The sort direction * Whether users can clear sorting (configured on `MatSort`) * The name of the column (not the ID) Accounting for all of these factors would have made the intl formatting too complicated. This does have the negative consequence of needing to set a description for every header. However, users can add a custom directive to set the description in a consistent way if they have an application with many tables. (cherry picked from commit ecd54f4)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Adds a description input for mat-sort-header so that developers can provide an accessible description (using AriaDescirber under the hood). Additionally update the accessibility section for the sort header's documentation with guidance on providing an accessible experience.
I decided to use this approach instead of expanding
MatSortHeaderIntl
because the message developers would want to set here depends on several bits of information, including:MatSort
)Accounting for all of these factors would have made the intl formatting too complicated.
This does have the negative consequence of needing to set a description for every header. However, users can add a custom directive to set the description in a consistent way if they have an application with many tables.
cc @zarend @amysorto