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(angular, react, vue): overlays no longer throw errors when used inside tests #24681

Merged
merged 9 commits into from
Feb 2, 2022

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Feb 1, 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)
  • 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?

Issue Number: resolves #24549, resolves #24590

In order to get custom elements defined when using controllers, we import the source component which would trick Stencil into including the compiled components in the overlays file. From there, we would register those compiled components with the Custom Elements Registry.

Unfortunately, this resulted in two issues:

  1. Action Sheet was being initialized after it was referenced by its controller (bug: action sheet controller referencing ActionSheet before initialized #24549).
  2. Registering the components this way assumed that everyone was using the custom elements build. This resulted in controllers breaking for Angular users (bug: Angular 13 Jest Tests fail while opening overlays: Cannot set property '$lazyInstance$' of undefined (present is not a function) #24590). When the controller was created, the custom elements version of the overlay was created before the lazy loaded version was created. However, Stencil was expecting the lazy loaded version as it contained additional information it needed.

What is the new behavior?

  • Rather than try and build on the previous bandaid, I feel it would be better to have the React and Vue integrations register their over overlay components.
  • This allows Angular to work with lazy loaded and React/Vue to work with custom elements.
  • When Angular switches over to use custom elements, it will need to do something similar to what is done for React/Vue in this PR.
  • The one tradeoff is people using @ionic/core and custom elements build will need to import and define the overlay component before they can use the controller. However, this aligns with what is expected when using core + CE build anyways. Developers need to call initialize() when using core directly, but this will be called for them when using a framework integration.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev Build: 6.0.5-dev.1643732746.a377f15

@liamdebeasi liamdebeasi requested a review from a team as a code owner February 1, 2022 16:40
@github-actions github-actions bot added package: core @ionic/core package package: react @ionic/react package package: vue @ionic/vue package labels Feb 1, 2022
Copy link
Contributor

@amandaejohnston amandaejohnston left a comment

Choose a reason for hiding this comment

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

Had a couple questions below 👀 Also, might be good to set up a tech debt ticket for Angular if you haven't done so already.

core/README.md Show resolved Hide resolved
packages/react/src/hooks/useController.ts Outdated Show resolved Hide resolved
@liamdebeasi
Copy link
Contributor Author

We have a ticket for the Angular custom elements build in FW-191, so I made sure to mention this change in that ticket as well.

core/README.md Outdated Show resolved Hide resolved
core/README.md Show resolved Hide resolved
packages/react/src/hooks/useIonActionSheet.ts Outdated Show resolved Hide resolved
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
3 participants