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

fix(popover): popover positions correctly on all frameworks #26306

Merged
merged 7 commits into from
Nov 22, 2022
Merged

Conversation

sean-perkins
Copy link
Contributor

@sean-perkins sean-perkins commented Nov 16, 2022

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
    • Some docs updates need to be made in the ionic-docs repo, in a separate PR. See the contributing guide for details.
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

In framework implementations, the popover will incorrectly position when using an alignment property such as top or bottom. The delay in timing between when the popover contents are mounted in the DOM vs. when the transition starts is too low, resulting in the popover content's bounding box height evaluating to 0 and the popover positioning incorrectly.

Issue URL: #25337

What is the new behavior?

  • React and Vue framework implementations use the new ionMount internal event when the popover is presented instead of willPresent. This allows the framework to mount the popover content earlier in the lifecycle of an overlay being presented.
  • Uses two request animation frame loops to provide enough time for the framework to mount the popover contents. In Angular/React a single request animation frame appears to be enough time, but for Vue, two is required. Opted for two to be consistent.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev-build: 6.3.8-dev.11668643678.159ccab8

@github-actions github-actions bot added package: core @ionic/core package package: react @ionic/react package package: vue @ionic/vue package labels Nov 16, 2022
@sean-perkins sean-perkins marked this pull request as ready for review November 17, 2022 00:07
@sean-perkins sean-perkins requested a review from a team as a code owner November 17, 2022 00:07
Comment on lines +475 to +476
raf(() => {
raf(async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to wait 2 frames just in Ionic Vue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Short answer, I'm not sure. I tested with a single request animation frame delay and compared against each and only Vue did not render the inner contents in time for the transition. Bumping to two consistently rendered correctly. I'm not familiar to the internals of how Vue handles rendering.

My intention with this bug fix is looking at a target for a patch release, but realizing we should be able to rip most/all of this away in a minor or major release, if we change either or both:

  1. The animation library to support asynchronous behavior.
  2. Add support to overlays to accurately track when content is mounted before running the transition.

Copy link
Contributor

@liamdebeasi liamdebeasi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the changes since they resolve some critical popover functionality. Can we add a tech debt ticket to research alternative implementations that do not rely on dual rafs?

@sean-perkins
Copy link
Contributor Author

Created FW-2875 to track, with additional detail as to what the problem we need to solve for is.

@sean-perkins sean-perkins merged commit be9a399 into main Nov 22, 2022
@sean-perkins sean-perkins deleted the FW-1619 branch November 22, 2022 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package package: react @ionic/react package package: vue @ionic/vue package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants