fix(vue): emit component-specific overlay events (#30688)

Issue number: resolves #30641

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

Currently, Vue modals do not emit `ionModal...` events. This happened
due to a change in the way the stencil output targets for Vue changed.
Christian [updated the
overlays](https://github.com/ionic-team/ionic-framework/pull/30227/files#diff-7e46aba01094c4917cd55e8eebd263fc4a297a2d62143f1ae30959ec4e023b6f)
to support the base events, but not the component-specific events.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

With this change, you'll be able to bind to the events as described in
the Ionic documentation.

## Does this introduce a breaking change?

- [ ] Yes
- [X] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer
for more information.
-->


## Other information

Current dev build:
```
8.7.5-dev.11758311583.14f4e9d9
```
This commit is contained in:
Shane
2025-09-23 10:22:48 -07:00
committed by GitHub
parent 36c56e71b6
commit 024d090122
3 changed files with 201 additions and 8 deletions

View File

@ -1,7 +1,11 @@
const testController = (overlay, shadow = false) => {
const selector = `.${overlay}-controller`;
cy.get(`ion-radio#${overlay}`).click();
cy.get('ion-radio#controller').click();
cy.get(`ion-radio#${overlay}`)
.scrollIntoView({ offset: { top: -100, left: 0 } })
.click({ force: true });
cy.get('ion-radio#controller')
.scrollIntoView({ offset: { top: -100, left: 0 } })
.click({ force: true });
cy.get('ion-button#present-overlay').click();
cy.get(selector).should('exist').should('be.visible');
@ -16,8 +20,12 @@ const testController = (overlay, shadow = false) => {
}
const testComponent = (overlay, shadow = false) => {
cy.get(`ion-radio#${overlay}`).click();
cy.get('ion-radio#component').click();
cy.get(`ion-radio#${overlay}`)
.scrollIntoView({ offset: { top: -100, left: 0 } })
.click({ force: true });
cy.get('ion-radio#component')
.scrollIntoView({ offset: { top: -100, left: 0 } })
.click({ force: true });
cy.get('ion-button#present-overlay').click();
cy.get(overlay).should('exist').should('be.visible');
@ -40,8 +48,12 @@ const testComponent = (overlay, shadow = false) => {
}
const testInlineOverlay = (overlay, shadow = false) => {
cy.get(`ion-radio#${overlay}`).click();
cy.get('ion-radio#component').click();
cy.get(`ion-radio#${overlay}`)
.scrollIntoView({ offset: { top: -100, left: 0 } })
.click({ force: true });
cy.get('ion-radio#component')
.scrollIntoView({ offset: { top: -100, left: 0 } })
.click({ force: true });
cy.get('ion-button#present-overlay').click();
cy.get(overlay).should('exist').should('be.visible');
@ -214,6 +226,135 @@ describe('Overlays', () => {
});
});
it('should fire long-form lifecycle events on overlays', () => {
cy.get('ion-radio#ion-modal').click();
cy.get('ion-radio#component').click();
cy.get('ion-button#present-overlay').click();
cy.get('ion-modal').should('exist');
testLongLifecycle('overlays', {
willPresent: 1,
didPresent: 1,
willDismiss: 0,
didDismiss: 0
});
cy.get('ion-modal #dismiss').click();
testLongLifecycle('overlays', {
willPresent: 1,
didPresent: 1,
willDismiss: 1,
didDismiss: 1
});
cy.get('ion-button#present-overlay').click();
cy.get('ion-modal').should('exist');
testLongLifecycle('overlays', {
willPresent: 2,
didPresent: 2,
willDismiss: 1,
didDismiss: 1
});
cy.get('ion-modal #dismiss').click();
testLongLifecycle('overlays', {
willPresent: 2,
didPresent: 2,
willDismiss: 2,
didDismiss: 2
});
});
it('should fire lifecycle events on controller overlays', () => {
cy.get('ion-radio#ion-modal').click();
cy.get('ion-radio#controller').click();
cy.get('ion-button#present-overlay').click();
cy.get('ion-modal').should('exist');
testLifecycle('overlays', {
willPresent: 1,
didPresent: 1,
willDismiss: 0,
didDismiss: 0
});
cy.get('ion-modal #dismiss').click();
testLifecycle('overlays', {
willPresent: 1,
didPresent: 1,
willDismiss: 1,
didDismiss: 1
});
cy.get('ion-button#present-overlay').click();
cy.get('ion-modal').should('exist');
testLifecycle('overlays', {
willPresent: 2,
didPresent: 2,
willDismiss: 1,
didDismiss: 1
});
cy.get('ion-modal #dismiss').click();
testLifecycle('overlays', {
willPresent: 2,
didPresent: 2,
willDismiss: 2,
didDismiss: 2
});
});
it('should fire long-form lifecycle events on controller overlays', () => {
cy.get('ion-radio#ion-modal').click();
cy.get('ion-radio#controller').click();
cy.get('ion-button#present-overlay').click();
cy.get('ion-modal').should('exist');
testLongLifecycle('overlays', {
willPresent: 1,
didPresent: 1,
willDismiss: 0,
didDismiss: 0
});
cy.get('ion-modal #dismiss').click();
testLongLifecycle('overlays', {
willPresent: 1,
didPresent: 1,
willDismiss: 1,
didDismiss: 1
});
cy.get('ion-button#present-overlay').click();
cy.get('ion-modal').should('exist');
testLongLifecycle('overlays', {
willPresent: 2,
didPresent: 2,
willDismiss: 1,
didDismiss: 1
});
cy.get('ion-modal #dismiss').click();
testLongLifecycle('overlays', {
willPresent: 2,
didPresent: 2,
willDismiss: 2,
didDismiss: 2
});
});
it('should unmount modal via component', () => {
cy.get('ion-radio#ion-modal').click();
cy.get('ion-radio#component').click();
@ -260,3 +401,9 @@ const testLifecycle = (selector, expected = {}) => {
cy.get(`[data-pageid=${selector}] #didDismiss`).should('have.text', expected.didDismiss);
}
const testLongLifecycle = (selector, expected = {}) => {
cy.get(`[data-pageid=${selector}] #ionModalWillPresent`).should('have.text', expected.willPresent);
cy.get(`[data-pageid=${selector}] #ionModalDidPresent`).should('have.text', expected.didPresent);
cy.get(`[data-pageid=${selector}] #ionModalWillDismiss`).should('have.text', expected.willDismiss);
cy.get(`[data-pageid=${selector}] #ionModalDidDismiss`).should('have.text', expected.didDismiss);
}