-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
fix(popover): dynamic width popover is positioned correctly #28072
Conversation
Run & review this pull request in StackBlitz Codeflow. |
|
||
this.ionMount.emit(); | ||
|
||
this.usersElement = await attachComponent(delegate, el, this.component, ['ion-page'], this.componentProps, inline); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving ionMount
above attachComponent isn't strictly necessary for modal, but I decided to make the change so we are at least consistent with ion-popover
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with minor suggestion.
@@ -449,6 +449,9 @@ export class Popover implements ComponentInterface, PopoverInterface { | |||
const { el } = this; | |||
|
|||
const { inline, delegate } = this.getDelegate(true); | |||
|
|||
this.ionMount.emit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be beneficial to add a comment to why it's important to have ionMount
above attachComponent
to prevent it being moved to a lower position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! Added in c4beade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Issue number: resolves #27190, resolves #24780
What is the current behavior?
Popovers with dynamic widths were not being positioned correctly relative to the trigger element. This was happening because the child component always had dimensions of 0 x 0. Ionic has logic built-in to wait for the child components to be rendered, but this was not working as intended for two reasons:
this.usersElement
was referencing the popover element itself not the user’s component. When callingdeepReady
onionic-framework/core/src/components/popover/popover.tsx
Line 477 in 01fc9b4
This is happening because we return
BaseComponent
fromattachComponent
which is a reference to the overlay:ionic-framework/core/src/utils/framework-delegate.ts
Line 133 in 01fc9b4
Other framework delegates return the actual child content:
ionic-framework/core/src/utils/framework-delegate.ts
Line 35 in 01fc9b4
ionic-framework/packages/react/src/framework-delegate.tsx
Line 31 in 01fc9b4
ionic-framework/packages/vue/src/framework-delegate.ts
Line 45 in 01fc9b4
attachComponent
is unable to return the correct element currently because the child content has not been mounted yet in this scenario.ionMount
is emitted afterattachComponent
resolves:ionic-framework/core/src/components/popover/popover.tsx
Line 466 in 01fc9b4
What is the new behavior?
ionMount
is emitted beforeattachComponent
runsattachComponent
now consistently returns the child view if present in the DOMDoes this introduce a breaking change?
Other information
Dev build:
7.3.2-dev.11693321763.15a54694