MatSelect overlayDir now private when updating from Angular 11 to 12. How do I access it now?

325 views
Skip to first unread message

Jeremy

unread,
Sep 15, 2021, 1:56:09 PM9/15/21
to angular-material2
In Angular 11, in node_modules\@angular\material\select there is a variable:

```
/**
     * Overlay pane containing the options.
     * @deprecated To be turned into a private API.
     * @breaking-change 10.0.0
     * @docs-private
     */
    overlayDir: CdkConnectedOverlay;
```

that in Angular 12 has now been changed to:
```
/** Overlay pane containing the options. */
    protected _overlayDir: CdkConnectedOverlay;
```

This of course breaks all of my usage of `overlayDir`  For example:

```
let selectionOverlay = this.quickFiltersSelect
              .overlayDir as CdkConnectedOverlay;
```
Gives me the TS error:
```Property 'overlayDir' does not exist on type 'MatSelect'```
...Which makes sense. Now it's protected. So I change .overlayDir to ._overlayDir and now get the TS error:
```
Property '_overlayDir' is protected and only accessible within class '_MatSelectBase<C>' and its subclasses.
```

I then imported _MatSelectBase but I am not sure what to replace it with, or if I should be accessing protected properties in this manner. I think `_MatSelectBase` is a generic, so it is looking for `_MatSelectBase<C>` but I am no longer sure I am on the right path.

Can anyone tell me where I have gone wrong, and what the solution might be?

Thank you.
Reply all
Reply to author
Forward
0 new messages