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

refactor(docs-infra): reimplement aio-select using mat-select #45937

Conversation

dario-piotrowicz
Copy link
Contributor

@dario-piotrowicz dario-piotrowicz commented May 9, 2022

the current aio-select component is implemented using buttons instead of
a native select element, this causes the component not to be very
accessible (screen readers for example do not tell the user that there
is a selection available, and not all keyboard navigation
functionalities work as per the wai-aria guidelines)

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

As mentioned in the commit description this is an attempt to make aio-select more accessible as I believe it currently is not

This is how it currently looks:

Screenshot at 2022-05-09 21-19-26

What is the new behavior?

This is how it looks with mat-select:

Screenshot at 2022-05-09 21-19-01

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

  • I've checked the code and the only places using the component are the api-list page and the version select on the left sidenav
  • This is just an idea, since we've got material I figured we could try reusing mat-select, if the change in style is undesirable I can scratch the change and just manually re-implement the component using the native select element
  • This relates but does not completely addresses Accessibility issues with version picker #44339
  • Most of the aio-select unit tests have been removed since they test basic functionalities which should be guaranteed by the mat-select out of the box (like the fact that the options show up when you click on the element, etc...)
  • I think the mat-select has a slight issue with the a11y of the label, I've opened an issue for that in the components repo (bug(mat-select): The selection is repeated twice (+) in screen readers  components#24899)

@pullapprove pullapprove bot requested a review from alxhub May 9, 2022 20:26
Comment on lines -44 to -49
it('should contain a symbol if hasSymbol is true', () => {
expect(getButtonSymbol()).toEqual(null);
host.showSymbol = true;
fixture.detectChanges();
expect(getButtonSymbol()).not.toEqual(null);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is one unit test I actually wanted to keep but I had issues implementing it since the span with the symbol is inside the mat-select and I couldn't find a way to query for it (I am not even sure if the mat-select content gets rendered in the tests) 😓

@AndrewKushnir AndrewKushnir requested review from gkalpak and removed request for alxhub May 9, 2022 22:47
@AndrewKushnir AndrewKushnir added action: review The PR is still awaiting reviews from at least one requested reviewer comp: docs-infra target: patch This PR is targeted for the next patch release labels May 9, 2022
@ngbot ngbot bot modified the milestone: Backlog May 9, 2022
@gkalpak gkalpak closed this May 13, 2022
@gkalpak gkalpak reopened this May 13, 2022
@mary-poppins
Copy link

You can preview e11d9f4 at https://pr45937-e11d9f4.ngbuilds.io/.

Copy link
Member

@gkalpak gkalpak left a comment

Choose a reason for hiding this comment

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

Generally lgtm 👍
I wonder what the payload size change would be.

Copy link
Contributor

@jessicajaniuk jessicajaniuk left a comment

Choose a reason for hiding this comment

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

Looks like there's some api-list tests that relied on a CSS class that was changed here that needs to be addressed. That and the simple lint issue should get this ready to merge.


import { MatSelectHarness } from '@angular/material/select/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { MatFormFieldHarness } from "@angular/material/form-field/testing";
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
import { MatFormFieldHarness } from "@angular/material/form-field/testing";
import { MatFormFieldHarness } from '@angular/material/form-field/testing';

Looks like aio tests are failing lint checks because of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool yeah, sorry for the failing tests, I'm on it 🙂

@dario-piotrowicz
Copy link
Contributor Author

Generally lgtm +1 I wonder what the payload size change would be.

yeah I was wondering the same too, I just thought of opening the PR and see what the ci says 🙈

let me fix the issues and will see how it looks 😅

the current aio-select component is implemented using buttons instead of
a native select element, this causes the component not to be very
accessible (screen readers for example do not tell the user that there
is a selection available, and not all keyboard navigation
functionalities work as per the wai-aria guidelines)
await dropdown.element(by.css('.form-select-button')).click();
const menuItem = dropdown.element(by.cssContainingText('.form-select-dropdown li', itemName));
await dropdown.element(by.css('mat-select')).click();
const menuItem = element(by.cssContainingText('mat-option', itemName));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here I had to remove the dropdown scoping/prefix, the issue being that the select options sit in their cdk-overlay-container div which is not a child of the dropdown so I needed to make the selection generic

(PS: I looked into using the material harnesses but I think that they have issues with protractor, with it being deprecated and whatnot, please let me know if I'm mistaken 😓)

@dario-piotrowicz
Copy link
Contributor Author

dario-piotrowicz commented May 13, 2022

@gkalpak the results are out....
Screenshot at 2022-05-13 22-43-16
Screenshot at 2022-05-13 22-42-55

Sorry I had no idea it would cause such a drastic increase! 😓 😱

I'm just closing this PR and will create a new one using a native select element (in that way I can also keep the look and feel exactly the same)

@gkalpak and @jessicajaniuk thanks a lot for the reviewing the PR 🙂 , sorry for the inconvenience 😓

@dario-piotrowicz dario-piotrowicz deleted the aio-select-refactor-to-use-mat-select branch May 13, 2022 21:47
dario-piotrowicz added a commit to dario-piotrowicz/angular that referenced this pull request May 15, 2022
improve the accessibility of the aio-select component so that it is
clear for screen reader users its functionality (currently it is
presented as a simple button), following the WAI-ARIA authoring
practices (see: https://www.w3.org/TR/wai-aria-practices/#combobox)

A first attempt in improving the accessibility of the component has been
tried in PR angular#45937 by replacing it with the material select component,
such implementation has however been scrapped since the increase of
payload sizes has proven prohibitively large

(also note that given native select elements haven't been used given the lack
of syling options for such elements)
dario-piotrowicz added a commit to dario-piotrowicz/angular that referenced this pull request May 15, 2022
improve the accessibility of the aio-select component so that it is
clear for screen reader users its functionality (currently it is
presented as a simple button), following the WAI-ARIA authoring
practices (see: https://www.w3.org/TR/wai-aria-practices/#combobox)

A first attempt in improving the accessibility of the component has been
tried in PR angular#45937 by replacing it with the material select component,
such implementation has however been scrapped since the increase of
payload sizes has proven prohibitively large

(also note that given native select elements haven't been used given the lack
of syling options for such elements)
dario-piotrowicz added a commit to dario-piotrowicz/angular that referenced this pull request May 15, 2022
improve the accessibility of the aio-select component so that it is
clear for screen reader users its functionality (currently it is
presented as a simple button), following the WAI-ARIA authoring
practices (see: https://www.w3.org/TR/wai-aria-practices/#combobox)

A first attempt in improving the accessibility of the component has been
tried in PR angular#45937 by replacing it with the material select component,
such implementation has however been scrapped since the increase of
payload sizes has proven prohibitively large

(also note that given native select elements haven't been used given the lack
of syling options for such elements)
dario-piotrowicz added a commit to dario-piotrowicz/angular that referenced this pull request May 15, 2022
improve the accessibility of the aio-select component so that it is
clear for screen reader users its functionality (currently it is
presented as a simple button), following the WAI-ARIA authoring
practices (see: https://www.w3.org/TR/wai-aria-practices/#combobox)

A first attempt in improving the accessibility of the component has been
tried in PR angular#45937 by replacing it with the material select component,
such implementation has however been scrapped since the increase of
payload sizes has proven prohibitively large

(also note that given native select elements haven't been used given the lack
of syling options for such elements)
dario-piotrowicz added a commit to dario-piotrowicz/angular that referenced this pull request May 16, 2022
improve the accessibility of the aio-select component so that it is
clear for screen reader users its functionality (currently it is
presented as a simple button), following the WAI-ARIA authoring
practices (see: https://www.w3.org/TR/wai-aria-practices/#combobox)

A first attempt in improving the accessibility of the component has been
tried in PR angular#45937 by replacing it with the material select component,
such implementation has however been scrapped since the increase of
payload sizes has proven prohibitively large

(also note that given native select elements haven't been used given the lack
of syling options for such elements)
dario-piotrowicz added a commit to dario-piotrowicz/angular that referenced this pull request May 24, 2022
improve the accessibility of the aio-select component so that it is
clear for screen reader users its functionality (currently it is
presented as a simple button), following the WAI-ARIA authoring
practices (see: https://www.w3.org/TR/wai-aria-practices/#combobox)

A first attempt in improving the accessibility of the component has been
tried in PR angular#45937 by replacing it with the material select component,
such implementation has however been scrapped since the increase of
payload sizes has proven prohibitively large

(also note that given native select elements haven't been used given the lack
of syling options for such elements)
dario-piotrowicz added a commit to dario-piotrowicz/angular that referenced this pull request May 24, 2022
improve the accessibility of the aio-select component so that it is
clear for screen reader users its functionality (currently it is
presented as a simple button), following the WAI-ARIA authoring
practices (see: https://www.w3.org/TR/wai-aria-practices/#combobox)

A first attempt in improving the accessibility of the component has been
tried in PR angular#45937 by replacing it with the material select component,
such implementation has however been scrapped since the increase of
payload sizes has proven prohibitively large

(also note that given native select elements haven't been used given the lack
of syling options for such elements)
dario-piotrowicz added a commit to dario-piotrowicz/angular that referenced this pull request May 24, 2022
improve the accessibility of the aio-select component so that it is
clear for screen reader users its functionality (currently it is
presented as a simple button), following the WAI-ARIA authoring
practices (see: https://www.w3.org/TR/wai-aria-practices/#combobox)

A first attempt in improving the accessibility of the component has been
tried in PR angular#45937 by replacing it with the material select component,
such implementation has however been scrapped since the increase of
payload sizes has proven prohibitively large

(also note that given native select elements haven't been used given the lack
of syling options for such elements)
jessicajaniuk pushed a commit that referenced this pull request Jun 10, 2022
improve the accessibility of the aio-select component so that it is
clear for screen reader users its functionality (currently it is
presented as a simple button), following the WAI-ARIA authoring
practices (see: https://www.w3.org/TR/wai-aria-practices/#combobox)

A first attempt in improving the accessibility of the component has been
tried in PR #45937 by replacing it with the material select component,
such implementation has however been scrapped since the increase of
payload sizes has proven prohibitively large

(also note that given native select elements haven't been used given the lack
of syling options for such elements)

PR Close #46013
jessicajaniuk pushed a commit that referenced this pull request Jun 10, 2022
improve the accessibility of the aio-select component so that it is
clear for screen reader users its functionality (currently it is
presented as a simple button), following the WAI-ARIA authoring
practices (see: https://www.w3.org/TR/wai-aria-practices/#combobox)

A first attempt in improving the accessibility of the component has been
tried in PR #45937 by replacing it with the material select component,
such implementation has however been scrapped since the increase of
payload sizes has proven prohibitively large

(also note that given native select elements haven't been used given the lack
of syling options for such elements)

PR Close #46013
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: review The PR is still awaiting reviews from at least one requested reviewer aio: preview target: patch This PR is targeted for the next patch release type: bug/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants