Skip to content

Commit df1ab95

Browse files
committed
fix(form-field): annotate base class with Directive for Ivy
This is a resubmit of #17022, excluding the portal changes. It marks the `MatFormFieldControl` as a directive because it's being extended by other directives which can cause errors under Ivy.
1 parent ef92091 commit df1ab95

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/material/form-field/form-field-control.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@
88

99
import {Observable} from 'rxjs';
1010
import {NgControl} from '@angular/forms';
11+
import {Directive, NgModule} from '@angular/core';
1112

1213

1314
/** An interface which allows a control to work inside of a `MatFormField`. */
15+
@Directive({
16+
// The @Directive with selector is required here because we're still running a lot of things
17+
// against ViewEngine where directives without selectors are not allowed.
18+
// TODO(crisbeto): convert to a selectorless Directive after we switch to Ivy.
19+
selector: 'do-not-use-abstract-mat-form-field-control',
20+
})
1421
export abstract class MatFormFieldControl<T> {
1522
/** The value of the control. */
1623
value: T | null;
@@ -67,3 +74,10 @@ export abstract class MatFormFieldControl<T> {
6774
/** Handles a click on the control's container. */
6875
abstract onContainerClick(event: MouseEvent): void;
6976
}
77+
78+
// TODO(crisbeto): remove when `MatFormFieldControl` becomes a selectorless Directive.
79+
@NgModule({
80+
declarations: [MatFormFieldControl as any],
81+
})
82+
export class DoNotUseMatFormFieldControlModule {
83+
}

src/material/form-field/public-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
export * from './form-field-module';
1010
export * from './error';
1111
export * from './form-field';
12-
export * from './form-field-control';
12+
export {MatFormFieldControl} from './form-field-control';
1313
export * from './form-field-errors';
1414
export * from './hint';
1515
export * from './placeholder';

0 commit comments

Comments
 (0)