Skip to content
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

bug(MATSELECT): Now that overlayDir is protected (_overlayDir) what is the best practice way of accessing this? #23625

Closed
khepf opened this issue Sep 23, 2021 · 5 comments
Labels
area: material/select needs: clarification The issue does not contain enough information for the team to determine if it is a real bug

Comments

@khepf
Copy link

khepf commented Sep 23, 2021

Reproduction

select.d.ts used to have:

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

But now, it's protected:

/** Overlay pane containing the options. */
    protected _overlayDir: CdkConnectedOverlay;

What is the best practices way of accessing this now that it is protected? I use overlayDir to modify the location of select dropdowns and I am not sure how to access this now that it is protected, or if I even should be accessing it in this manner any longer. Is there a new preferred way to modify the location of select dropdowns?

Expected Behavior

What behavior were you expecting to see?

  • overlayDir as an accessible option

Actual Behavior

What behavior did you actually see?

  • _overlayDir is now protected

Environment

  • Angular: 12.2.5
  • CDK/Material: 12.2.5
  • Browser(s): Chrome, Safari
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows
@khepf khepf added the needs triage This issue needs to be triaged by the team label Sep 23, 2021
@crisbeto
Copy link
Member

The overlayRef was exposed accidentally and now it has been hidden so there's no way of accessing it. What were you trying to do with it?

@crisbeto crisbeto added area: material/select needs: clarification The issue does not contain enough information for the team to determine if it is a real bug and removed needs triage This issue needs to be triaged by the team labels Sep 28, 2021
@khepf
Copy link
Author

khepf commented Sep 30, 2021

It is the overlayDir.positions I had been accessing. For the purpose of offsetting select columns so they appear below the select box, not on top of it. For example:

let selectionOverlay = this.matSelect.overlayDir as CdkConnectedOverlay;
      selectionOverlay.positions = [
        {
          offsetX: 1,
          offsetY: 0,
          originX: 'start',
          originY: 'bottom',
          overlayX: 'start',
          overlayY: 'top'
        }
      ];

Is there a more conventional, best practices way to do so?

@crisbeto
Copy link
Member

We're moving away from positioning the dropdown on top of the select. You can try our new select based on top of MDC's styles. The API and behavior is exactly the same since it shares the same base class as the current select, but the CSS will be slightly different and the dropdown is only positioned above/below. You can try it by importing MatSelectModule from @angular/material-experimental/mdc-select instead of @angular/material/select.

@crisbeto
Copy link
Member

Closing due to inactivity.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/select needs: clarification The issue does not contain enough information for the team to determine if it is a real bug
Projects
None yet
Development

No branches or pull requests

2 participants