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(vue): cache attached view reference #26694

Merged
merged 4 commits into from
Jan 30, 2023
Merged

Conversation

sean-perkins
Copy link
Contributor

@sean-perkins sean-perkins commented Jan 27, 2023

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?

Developers using Vue can run into an error when using an ion-select that presents a popover of options. The Vue delegate was incorrectly assuming that a component instance would always be passed as the argument to attachViewToDom.

This is not the case for ion-select, where a string of the tag name is used: https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/select/select.tsx#L414

Issue URL: #26643 (comment)
resolves #26695

What is the new behavior?

  • Caches the reference to the created element, so the WeakMap always receives an object to that can be used for looking up and unmounting an overlay.
  • Refactored the property to better signal that it can be an "object" (any) or a string. Note: Because any will overwrite the types, this does nothing from a typings perspective. This is just a visual signal to a developer.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Repro: https://github.com/acoldfox/ionic-select-issue (you will need to install the dev-build to verify)

Dev-build: 6.5.2-dev.11674852369.1c9fe737

@stackblitz
Copy link

stackblitz bot commented Jan 27, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions github-actions bot added the package: vue @ionic/vue package label Jan 27, 2023
@sean-perkins sean-perkins marked this pull request as ready for review January 27, 2023 20:56
@sean-perkins sean-perkins requested a review from a team January 27, 2023 20:56
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.

We need a test for this. Also why does this issue not impact Ionic React?

@liamdebeasi
Copy link
Contributor

Also be sure to note that this fixes #26695 when merging

@sean-perkins
Copy link
Contributor Author

sean-perkins commented Jan 30, 2023

React only uses the framework delegate for IonNav. No other part of the implementation uses that logic. Vue on the other hand uses the framework delegate for any implementation that uses the createController approach (modal, popover, alert, action sheet, loading, picker and toast). This problem is unique to ion-select/ion-popover, in the way that ion-select passes a tag name as a string instead of a component instance to the attachViewToDom API.

I'll confirm #26695 today & fill in a test 👍

Edit: I misunderstood what issue was being linked to. I will reference that issue when merging, I need to also confirm the original intended fix behind this change against the dev-build.

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.

Good to go once we have a test. Thanks for taking care of this!

@sean-perkins
Copy link
Contributor Author

Ok - test case has been added.

Also confirmed against the original root issue: https://github.com/raymer/ionic-modal-bug that the expected behavior still occurs after this change.

@sean-perkins sean-perkins merged commit 7c00897 into main Jan 30, 2023
@sean-perkins sean-perkins deleted the fix/vue-select-popover branch January 30, 2023 20:58
liamdebeasi pushed a commit that referenced this pull request Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: vue @ionic/vue package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: popover select does not work in @ionic/core@6.4+
2 participants