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/select): remove unnecessary announcement #28252

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion src/material/select/BUILD.bazel
Expand Up @@ -63,7 +63,6 @@ ng_test_library(
),
deps = [
":select",
"//src/cdk/a11y",
"//src/cdk/bidi",
"//src/cdk/keycodes",
"//src/cdk/overlay",
Expand Down
14 changes: 0 additions & 14 deletions src/material/select/select.spec.ts
Expand Up @@ -39,7 +39,6 @@ import {
ComponentFixture,
fakeAsync,
flush,
inject,
TestBed,
tick,
} from '@angular/core/testing';
Expand All @@ -63,7 +62,6 @@ import {
} from '@angular/material/form-field';
import {By} from '@angular/platform-browser';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {LiveAnnouncer} from '@angular/cdk/a11y';
import {Subject, Subscription, EMPTY, Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import {MatSelectModule} from './index';
Expand Down Expand Up @@ -505,18 +503,6 @@ describe('MDC-based MatSelect', () => {
flush();
}));

it('should announce changes via the keyboard on a closed select', fakeAsync(
inject([LiveAnnouncer], (liveAnnouncer: LiveAnnouncer) => {
spyOn(liveAnnouncer, 'announce');

dispatchKeyboardEvent(select, 'keydown', RIGHT_ARROW);

expect(liveAnnouncer.announce).toHaveBeenCalledWith('Steak', jasmine.any(Number));

flush();
}),
));

it('should not throw when reaching a reset option using the arrow keys on a closed select', fakeAsync(() => {
fixture.componentInstance.foods = [
{value: 'steak-0', viewValue: 'Steak'},
Expand Down
8 changes: 0 additions & 8 deletions src/material/select/select.ts
Expand Up @@ -937,14 +937,6 @@ export class MatSelect
} else if (!this.multiple) {
const previouslySelectedOption = this.selected;
manager.onKeydown(event);
const selectedOption = this.selected;

// Since the value has changed, we need to announce it ourselves.
if (selectedOption && previouslySelectedOption !== selectedOption) {
// We set a duration on the live announcement, because we want the live element to be
// cleared after a while so that users can't navigate to it using the arrow keys.
this._liveAnnouncer.announce((selectedOption as MatOption).viewValue, 10000);
}
}
}

Expand Down