Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions core/src/components/modal/animations/md.enter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,19 @@ const createEnterAnimation = () => {
})
.afterClearStyles(['pointer-events']);

const wrapperAnimation = createAnimation().keyframes([
{ offset: 0, opacity: 0.01, transform: 'translateY(40px)' },
{ offset: 1, opacity: 1, transform: `translateY(0px)` },
]);
/**
* The finished animation must not stay applied to the wrapper.
* An element with an applied opacity animation is a backdrop root,
* so `backdrop-filter` inside the modal could not see the page
* behind it. The end state is set as inline styles instead.
*/
const wrapperAnimation = createAnimation()
.fill('backwards')
.afterStyles({ opacity: '1', transform: 'translateY(0px)' })
.keyframes([
{ offset: 0, opacity: 0.01, transform: 'translateY(40px)' },
{ offset: 1, opacity: 1, transform: `translateY(0px)` },
]);

return { backdropAnimation, wrapperAnimation, contentAnimation: undefined };
};
Expand Down
36 changes: 36 additions & 0 deletions core/src/components/modal/test/animations/modal.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,39 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ config, title }) =>
});
});
});

configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ config, title }) => {
test.describe(title('modal: animations'), () => {
test('should not keep the enter animation applied to the wrapper', async ({ page }, testInfo) => {
testInfo.annotations.push({
type: 'issue',
description: 'https://github.com/ionic-team/ionic-framework/issues/31603',
});

await page.setContent(
`
<ion-modal></ion-modal>
`,
config
);

const ionModalDidPresent = await page.spyOnEvent('ionModalDidPresent');
const modal = page.locator('ion-modal');

await modal.evaluate((el: HTMLIonModalElement) => el.present());
await ionModalDidPresent.next();

const wrapper = page.locator('ion-modal .modal-wrapper');

/**
* An applied opacity animation makes the wrapper a backdrop root,
* which breaks `backdrop-filter` on content inside the modal.
*/
const wrapperAnimations = await wrapper.evaluate((el: HTMLElement) => el.getAnimations().length);
expect(wrapperAnimations).toBe(0);

await expect(wrapper).toHaveCSS('opacity', '1');
await expect(wrapper).toHaveCSS('transform', 'matrix(1, 0, 0, 1, 0, 0)');
});
});
});
Loading