-
Notifications
You must be signed in to change notification settings - Fork 35
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
misaligned if parent initially hidden #86
Comments
The way we're structuring our usage of popper, we insert the poppers lazily when the user actually needs them: {{#my-context-menu as |menu|}}
{{#menu.button}}
Download
{{#if buttonIsHovered}}
{{#ember-popper-targeting-parent class='tooltip'}}
Download the thing
{{/ember-popper-targeting-parent}}
{{/if}}
{{/menu.button}}
{{/my-context-menu}} A separate tooltip component handles the logic of |
I opened floating-ui/floating-ui#630 on the upstream Popper.js library since this can happen without ember. |
A11y is precisely our reason for wanting the tooltip to always be in the DOM.
Indeed I have just such a component. The problem is that it doesn't have access to the One possible solution would be to add some a hook like |
Another possible solution would be something like // ember-popper components will call popper.scheduleUpdate any time
// any passed attribute changes
didReceiveAttrs() {
if (this._popper) { this._popper.scheduleUpdate() }
return this._super(...arguments)
} Then I could "invoke" that with {{#ember-popper-targeting-parent
class=(concat 'tooltip ' (if hidden 'tooltip--hidden'))}} This is more automatic, but it doesn't communicate intent as well. |
@jamesarosen you can use the EDIT: |
This is perfect. Thanks! @kybishop do you have any interest in an
|
I do need the same |
Woot! I'd like to keep ember-popper as just the positioning abstraction layer since it is used by other tooltip libraries. I worry that adding our own tooltip component would bloat consuming addons. Ember-popper was initially built for use in ember-attacher, and is now used in ember-bootstrap as well. It is more of a spiritual successor to ember-tether than anything else. |
Duplicating logic from Abstracting the parent-finding behavior out to a mixin might be nice... I wonder what implications that would have for code-readability in consuming addons. |
I'd prefer a utility function to a mixin, or both if possible. We're trying to avoid using mixins until a solid native class based solution arises in the JS ecosystem. |
It turns out that I can avoid copying I think this resolves all my outstanding issues. |
I have nested overlays:
When the page first renders, all of those elements are in the DOM but hidden. That mean that
this._initialParentNode
is well defined, butthis._initialParentNode.offsetParent
isnull
. This causes the tooltip (popper content) to be aligned to the top-left of the screen.If I open the context menu and then scroll or resize the viewport then the tooltip pops right into place.
There's no good way for the parent to inform the
{{ember-popper-targeting-parent}}
that its "rendering state" has changed. I also don't love the idea that calling contexts should be responsible for knowing about this limitation.Unfortunately, the only solution I've come up with is to have
{{ember-popper-targeting-parent}}
(orember-popper-base
) callpopper.scheduleUpdate()
every X ms, which is wasteful for most cases.It might be possible to do this with a mutation observer on the
_initialParentNode
, but I'm not sure that such an observer would fire if an ancestor of that element changes an attribute or style.Possibly related: floating-ui/floating-ui#537
The text was updated successfully, but these errors were encountered: