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(core/modal): use percentage to align modal centered #836

Merged
merged 3 commits into from
Oct 12, 2023
Merged
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
9 changes: 6 additions & 3 deletions packages/core/src/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class Modal {
private slideInModal() {
const duration = this.animation ? Animation.mediumTime : 0;

let transformY = this.centered ? '-50' : 40;
let transformY = this.centered ? '-50%' : 40;

anime({
targets: this.dialog,
Expand All @@ -108,7 +108,7 @@ export class Modal {
private slideOutModal(completeCallback: Function) {
const duration = this.animation ? Animation.mediumTime : 0;

let transformY = this.centered ? '-50' : 40;
let transformY = this.centered ? '-50%' : 40;

anime({
targets: this.dialog,
Expand Down Expand Up @@ -217,7 +217,10 @@ export class Modal {
aria-modal={a11yBoolean(true)}
aria-describedby={this.ariaAttributes['aria-describedby']}
aria-labelledby={this.ariaAttributes['aria-labelledby']}
class={`modal modal-size-${this.size}`}
class={{
modal: true,
[`modal-size-${this.size}`]: true,
}}
onKeyDown={(e) => {
if (e.key === 'Escape' && this.keyboard === false) {
e.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ regressionTest.describe('basic navigation mobile', () => {
});

regressionTest('mobile expanded', async ({ page }) => {
regressionTest.skip(
!!process.env['CI'],
'TODO: Fix flaky behavior on github runner'
);

await page.goto('basic-navigation/mobile');
await page.setViewportSize(viewPorts.sm);

Expand Down
16 changes: 16 additions & 0 deletions packages/core/src/tests/modal/modal.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,19 @@ test('modal with dropdown', async ({ mount, page }) => {
});
}
);

test('modal should show centered', async ({ mount, page }) => {
await mount(`
<ix-modal centered>
<div style="height: 500px">Some content</div>
</ix-modal>
`);
const modal = page.locator('ix-modal');
await expect(modal).toHaveClass(/hydrated/);

await modal.evaluate((modal: HTMLIxModalElement) => modal.showModal());

// Wait until anime.js perform the slideIn animation
await page.waitForTimeout(2000);
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.