Skip to content

Commit

Permalink
fix(multiple): add inject flags to manual injector calls (#22922)
Browse files Browse the repository at this point in the history
Fixes a few more cases like #22665 where we were injecting something optionally, but we weren't passing the optional injector flag.

(cherry picked from commit fc8a6f9)
  • Loading branch information
crisbeto authored and wagnermaciel committed Jun 10, 2021
1 parent 383f7b6 commit 2e2f755
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/cdk-experimental/dialog/dialog.ts
Expand Up @@ -16,7 +16,8 @@ import {
ComponentRef,
OnDestroy,
Type,
StaticProvider
StaticProvider,
InjectFlags
} from '@angular/core';
import {ComponentPortal, TemplatePortal} from '@angular/cdk/portal';
import {of as observableOf, Observable, Subject, defer} from 'rxjs';
Expand Down Expand Up @@ -285,8 +286,8 @@ export class Dialog implements OnDestroy {
{provide: DIALOG_DATA, useValue: config.data}
];

if (config.direction &&
(!userInjector || !userInjector.get<Directionality | null>(Directionality, null))) {
if (config.direction && (!userInjector ||
!userInjector.get<Directionality | null>(Directionality, null, InjectFlags.Optional))) {
providers.push({
provide: Directionality,
useValue: {value: config.direction, change: observableOf()}
Expand Down
5 changes: 3 additions & 2 deletions src/material/bottom-sheet/bottom-sheet.ts
Expand Up @@ -20,6 +20,7 @@ import {
Inject,
OnDestroy,
StaticProvider,
InjectFlags,
} from '@angular/core';
import {of as observableOf} from 'rxjs';
import {MAT_BOTTOM_SHEET_DATA, MatBottomSheetConfig} from './bottom-sheet-config';
Expand Down Expand Up @@ -191,8 +192,8 @@ export class MatBottomSheet implements OnDestroy {
{provide: MAT_BOTTOM_SHEET_DATA, useValue: config.data}
];

if (config.direction &&
(!userInjector || !userInjector.get<Directionality | null>(Directionality, null))) {
if (config.direction && (!userInjector ||
!userInjector.get<Directionality | null>(Directionality, null, InjectFlags.Optional))) {
providers.push({
provide: Directionality,
useValue: {value: config.direction, change: observableOf()}
Expand Down
5 changes: 3 additions & 2 deletions src/material/dialog/dialog.ts
Expand Up @@ -20,6 +20,7 @@ import {
Directive,
Inject,
Injectable,
InjectFlags,
InjectionToken,
Injector,
OnDestroy,
Expand Down Expand Up @@ -307,8 +308,8 @@ export abstract class _MatDialogBase<C extends _MatDialogContainerBase> implemen
{provide: this._dialogRefConstructor, useValue: dialogRef}
];

if (config.direction &&
(!userInjector || !userInjector.get<Directionality | null>(Directionality, null))) {
if (config.direction && (!userInjector ||
!userInjector.get<Directionality | null>(Directionality, null, InjectFlags.Optional))) {
providers.push({
provide: Directionality,
useValue: {value: config.direction, change: observableOf()}
Expand Down

0 comments on commit 2e2f755

Please sign in to comment.