Skip to content

[Feat]: Support custom boundaries element in overlay-trigger #2568

@dialupdev

Description

@dialupdev

Code of conduct

  • I agree to follow this project's code of conduct.

Impacted component(s)

overlay-trigger

Description of the requested feature

I would to set both the position and width of my popover relative to an element besides the trigger element. In other words, I want to select a specific element from the DOM to use as my "boundaries element".

Here's my example. In this scenario, I want the sp-popover to be contained within the pink box. I also want the width of the popover to match the box. I want the pink box to define the boundaries of the popover.
https://studio.webcomponents.dev/edit/GnpL4UwD0h9BAbqV9DOf/src/index.ts?p=stories

Mockups or screenshots

What I get:
current

What I want:
future

Implementation notes or ideas

@pinkhominid mentioned to me that Popper has a preventOverflow plugin that may address this case.
https://popper.js.org/docs/v2/modifiers/prevent-overflow/

Also, in React Spectrum we had a boundariesElement prop that provided this behavior.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions