Skip to content

refactor(multiple): remove visually hidden styles from core #29812

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

Merged
merged 1 commit into from
Oct 18, 2024
Merged
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
1 change: 1 addition & 0 deletions src/cdk/a11y/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ng_module(
"//src/cdk/layout",
"//src/cdk/observers",
"//src/cdk/platform",
"//src/cdk/private",
"@npm//@angular/core",
"@npm//rxjs",
],
Expand Down
2 changes: 2 additions & 0 deletions src/cdk/a11y/aria-describer/aria-describer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {DOCUMENT} from '@angular/common';
import {Injectable, OnDestroy, APP_ID, inject} from '@angular/core';
import {Platform} from '@angular/cdk/platform';
import {addAriaReferencedId, getAriaReferenceIds, removeAriaReferencedId} from './aria-reference';
import {_CdkPrivateStyleLoader, _VisuallyHiddenLoader} from '@angular/cdk/private';

/**
* Interface used to register message elements and keep a count of how many registrations have
Expand Down Expand Up @@ -69,6 +70,7 @@ export class AriaDescriber implements OnDestroy {
constructor(...args: unknown[]);

constructor() {
inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
this._id = inject(APP_ID) + '-' + nextId++;
}

Expand Down
5 changes: 4 additions & 1 deletion src/cdk/a11y/focus-trap/focus-trap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
inject,
} from '@angular/core';
import {InteractivityChecker} from '../interactivity-checker/interactivity-checker';
import {_CdkPrivateStyleLoader, _VisuallyHiddenLoader} from '@angular/cdk/private';

/**
* Class that allows for trapping focus within a DOM element.
Expand Down Expand Up @@ -378,7 +379,9 @@ export class FocusTrapFactory {
private _injector = inject(Injector);

constructor(...args: unknown[]);
constructor() {}
constructor() {
inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
}

/**
* Creates a focus-trapped region around the given element.
Expand Down
5 changes: 4 additions & 1 deletion src/cdk/a11y/live-announcer/live-announcer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
LIVE_ANNOUNCER_ELEMENT_TOKEN,
LIVE_ANNOUNCER_DEFAULT_OPTIONS,
} from './live-announcer-tokens';
import {_CdkPrivateStyleLoader, _VisuallyHiddenLoader} from '@angular/cdk/private';

let uniqueIds = 0;

Expand Down Expand Up @@ -256,7 +257,9 @@ export class CdkAriaLive implements OnDestroy {

constructor(...args: unknown[]);

constructor() {}
constructor() {
inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
}

ngOnDestroy() {
if (this._subscription) {
Expand Down
3 changes: 2 additions & 1 deletion src/material/badge/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
ANIMATION_MODULE_TYPE,
} from '@angular/core';
import {ThemePalette} from '@angular/material/core';
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
import {_CdkPrivateStyleLoader, _VisuallyHiddenLoader} from '@angular/cdk/private';

let nextId = 0;

Expand Down Expand Up @@ -158,6 +158,7 @@ export class MatBadge implements OnInit, OnDestroy {

constructor() {
inject(_CdkPrivateStyleLoader).load(_MatBadgeStyleLoader);
inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);

if (typeof ngDevMode === 'undefined' || ngDevMode) {
const nativeElement = this._elementRef.nativeElement;
Expand Down
3 changes: 2 additions & 1 deletion src/material/chips/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {Subject, Subscription, merge} from 'rxjs';
import {MatChipAction} from './chip-action';
import {MatChipAvatar, MatChipRemove, MatChipTrailingIcon} from './chip-icons';
import {MAT_CHIP, MAT_CHIP_AVATAR, MAT_CHIP_REMOVE, MAT_CHIP_TRAILING_ICON} from './tokens';
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
import {_CdkPrivateStyleLoader, _VisuallyHiddenLoader} from '@angular/cdk/private';

let uid = 0;

Expand Down Expand Up @@ -247,6 +247,7 @@ export class MatChip implements OnInit, AfterViewInit, AfterContentInit, DoCheck

constructor() {
inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
const animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true});
this._animationsDisabled = animationMode === 'NoopAnimations';
this._monitorFocus();
Expand Down
5 changes: 1 addition & 4 deletions src/material/core/_core.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
@use '@angular/cdk';
@use './tokens/m2/mat/app' as tokens-mat-app;
@use './tokens/token-utils';
@use './style/elevation';

// Mixin that renders all of the core styles that are not theme-dependent.
@mixin core() {
@include cdk.a11y-visually-hidden();
}
@mixin core() {}

// Emits the mat-app-background CSS class. This predefined class sets the
// background color and text color of an element.
Expand Down
3 changes: 2 additions & 1 deletion src/material/core/option/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {MatOptionParentComponent, MAT_OPTION_PARENT_COMPONENT} from './option-pa
import {MatRipple} from '../ripple/ripple';
import {MatPseudoCheckbox} from '../selection/pseudo-checkbox/pseudo-checkbox';
import {_StructuralStylesLoader} from '../focus-indicators/structural-styles';
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
import {_CdkPrivateStyleLoader, _VisuallyHiddenLoader} from '@angular/cdk/private';

/**
* Option IDs need to be unique across components, so this counter exists outside of
Expand Down Expand Up @@ -147,6 +147,7 @@ export class MatOption<T = any> implements FocusableOption, AfterViewChecked, On
constructor(...args: unknown[]);
constructor() {
inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
this._signalDisableRipple = !!this._parent && isSignal(this._parent.disableRipple);
}

Expand Down
2 changes: 2 additions & 0 deletions src/material/datepicker/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {MatYearView} from './year-view';
import {MAT_SINGLE_DATE_SELECTION_MODEL_PROVIDER, DateRange} from './date-selection-model';
import {MatIconButton, MatButton} from '@angular/material/button';
import {CdkMonitorFocus} from '@angular/cdk/a11y';
import {_CdkPrivateStyleLoader, _VisuallyHiddenLoader} from '@angular/cdk/private';

let calendarHeaderId = 1;

Expand Down Expand Up @@ -68,6 +69,7 @@ export class MatCalendarHeader<D> {
constructor(...args: unknown[]);

constructor() {
inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
const changeDetectorRef = inject(ChangeDetectorRef);
this.calendar.stateChanges.subscribe(() => changeDetectorRef.markForCheck());
}
Expand Down
2 changes: 2 additions & 0 deletions src/material/datepicker/datepicker-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import {matDatepickerAnimations} from './datepicker-animations';
import {createMissingDateImplError} from './datepicker-errors';
import {DateFilterFn} from './datepicker-input-base';
import {MatDatepickerIntl} from './datepicker-intl';
import {_CdkPrivateStyleLoader, _VisuallyHiddenLoader} from '@angular/cdk/private';

/** Used to generate a unique ID for each datepicker instance. */
let datepickerUid = 0;
Expand Down Expand Up @@ -202,6 +203,7 @@ export class MatDatepickerContent<S, D = ExtractDateTypeFromSelection<S>>
constructor(...args: unknown[]);

constructor() {
inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
const intl = inject(MatDatepickerIntl);

this._closeButtonText = intl.closeCalendarLabel;
Expand Down
2 changes: 2 additions & 0 deletions src/material/datepicker/month-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
MatDateRangeSelectionStrategy,
MAT_DATE_RANGE_SELECTION_STRATEGY,
} from './date-range-selection-strategy';
import {_CdkPrivateStyleLoader, _VisuallyHiddenLoader} from '@angular/cdk/private';

const DAYS_PER_WEEK = 7;

Expand Down Expand Up @@ -221,6 +222,7 @@ export class MatMonthView<D> implements AfterContentInit, OnChanges, OnDestroy {
constructor(...args: unknown[]);

constructor() {
inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
if (typeof ngDevMode === 'undefined' || ngDevMode) {
if (!this._dateAdapter) {
throw createMissingDateImplError('DateAdapter');
Expand Down
3 changes: 2 additions & 1 deletion src/material/stepper/step-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {CdkStepHeader, StepState} from '@angular/cdk/stepper';
import {_StructuralStylesLoader, MatRipple, ThemePalette} from '@angular/material/core';
import {MatIcon} from '@angular/material/icon';
import {NgTemplateOutlet} from '@angular/common';
import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
import {_CdkPrivateStyleLoader, _VisuallyHiddenLoader} from '@angular/cdk/private';

@Component({
selector: 'mat-step-header',
Expand Down Expand Up @@ -90,6 +90,7 @@ export class MatStepHeader extends CdkStepHeader implements AfterViewInit, OnDes
super();

inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
inject(_CdkPrivateStyleLoader).load(_VisuallyHiddenLoader);
const changeDetectorRef = inject(ChangeDetectorRef);
this._intlSubscription = this._intl.changes.subscribe(() => changeDetectorRef.markForCheck());
}
Expand Down
Loading