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

Define a bounding box for overlay other than documentElement #15894

Open
awormasi opened this issue Apr 24, 2019 · 2 comments
Open

Define a bounding box for overlay other than documentElement #15894

awormasi opened this issue Apr 24, 2019 · 2 comments
Labels
area: cdk/overlay feature This issue represents a new feature or feature request rather than a bug or bug fix P4 A relatively minor issue that is not relevant to core functions

Comments

@awormasi
Copy link

awormasi commented Apr 24, 2019

Please describe the feature you would like to request.

I would like the ability to define a bounding area where the tooltip is constrained to. Currently, the overlay bounding box is set to top: 0px; left: 0px; height: 100%; width: 100% but I would like to define these programmatically or pass an element ref to use as a template for the bounding box calculation. I know I can add a class to the overlay to change this but it has to be dynamic and respond to resizing an element whose size represents what the overlay bounds should be.

What is the use-case or motivation for this proposal?

The app has a requirement to restrict the tooltip location over a certain area and not allow it to overflow over surrounding elements. For example, using a tooltip to provide more detail over a chart cursor but the tooltip should be constrained to just the chart area.

This isn't the exact scenario but you can see the tooltip overflows the mat-card area here. I want to be able to push the tooltip into the mat-card area.
https://stackblitz.com/edit/angular6-material-components-demo-overlay-container

Is there anything else we should know?

Angular 7.2.4
Material 7.2.1

In FlexibleConnectedPositionStrategy, perhaps there could be an optional sizingEl property to use other than the documentElement. I haven't been able to test this since it's not extendable.

withSizingElement(sizingElement: HTMLElement): this {
    this._sizingEl = sizingElement;
    return this;
  }

private _getNarrowedViewportRect(): ClientRect {
    const el = this._sizingEl || this._document.documentElement;
    const width = el!.clientWidth;
    const height = el!.clientHeight;
    ...
  }

Something similar will have to be done to get the top and left from the sizing element:

getScrollPosition(referenceElement?: HTMLElement): ScrollPosition {
  if (!this._platform.isBrowser) {
    return {top: 0, left: 0};
  }

  const el = referenceElement || document.documentElement!;
  const rect = el.getBoundingClientRect();
  const top = -rect.top || el.scrollTop || 0;
  const left = -rect.left || el.scrollLeft || 0;

  return {top, left};
}
@andrewseguin andrewseguin added P4 A relatively minor issue that is not relevant to core functions feature This issue represents a new feature or feature request rather than a bug or bug fix labels May 6, 2019
@angular-robot
Copy link
Contributor

angular-robot bot commented Feb 21, 2022

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@angular-robot
Copy link
Contributor

angular-robot bot commented Mar 13, 2022

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/overlay feature This issue represents a new feature or feature request rather than a bug or bug fix P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

2 participants