Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Enhancement: Replacing overlayDir: CdkConnectedOverlay from MatSelectSearchComponent #208

Closed
evoltafreak opened this issue Feb 11, 2020 · 3 comments · Fixed by #209
Closed

Comments

@evoltafreak
Copy link
Contributor

Describe the enhancement:
Since the overlayDir: CdkConnectedOverlay property in the MatSelect class will be deprecated soon in Angular 10, you should consider to replace it in the MatSelectSearchComponent with following code.

Describe the solution

this.matSelect.openedChange
      .pipe(takeUntil(this._onDestroy))
      .subscribe((opened: boolean) => {
        if (opened) {
          // note: this is hacky, but currently there is no better way to do this
          let element: HTMLElement = this.searchSelectInput.nativeElement;
          let overlayElement: HTMLElement;
          while (element = element.parentElement) {
            if (element.classList.contains('cdk-overlay-pane')) {
              overlayElement = element;
              break;
            }
          }
          if (overlayElement) {
            overlayElement.classList.add(overlayClass);
          }
        }
      });

Also consider to run the following test should show a search field and focus it when opening the select synchronous in the MatSelectSearchTestComponent to make all tests successful again.

Gruess
Evoltafreak

@macjohnny
Copy link
Member

@evoltafreak thanks for suggesting this code change. would you like to file a PR for this?

@evoltafreak
Copy link
Contributor Author

@macjohnny I just opened a PR #209.

@macjohnny
Copy link
Member

@evoltafreak thanks a lot!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants