Skip to content

fix(modal): allow for custom dialog implementations #25630

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

Merged
merged 7 commits into from
Jul 15, 2022
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
80 changes: 80 additions & 0 deletions core/src/components/modal/test/custom-dialog/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Modal - Custom Dialog</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
<script src="../../../../../scripts/testing/scripts.js"></script>
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
<style>
ion-modal {
--width: fit-content;
--min-width: 250px;
--height: fit-content;
--border-radius: 6px;
--box-shadow: 0 28px 48px rgba(0, 0, 0, 0.4);
}

h1 {
margin: 20px 20px 10px 20px;
}

ion-icon {
margin-right: 6px;

width: 48px;
height: 48px;

padding: 4px 0;

color: #aaaaaa;
}

.wrapper {
margin-bottom: 10px;
}
</style>
</head>

<body>
<ion-app>
<div class="ion-page">
<ion-header>
<ion-toolbar>
<ion-title>Modal - Custom Dialog</ion-title>
</ion-toolbar>
</ion-header>

<ion-content class="ion-padding">
<ion-button id="custom-modal">Open Custom Dialog</ion-button>
<ion-modal trigger="custom-modal">
<div class="wrapper">
<h1>Dialog header</h1>

<ion-list lines="none">
<ion-item button="true" detail="false">
<ion-icon name="person-circle"></ion-icon>
<ion-label>Item 1</ion-label>
</ion-item>
<ion-item button="true" detail="false">
<ion-icon name="person-circle"></ion-icon>
<ion-label>Item 2</ion-label>
</ion-item>
<ion-item button="true" detail="false">
<ion-icon name="person-circle"></ion-icon>
<ion-label>Item 3</ion-label>
</ion-item>
</ion-list>
</div>
</ion-modal>
</ion-content>
</div>
</ion-app>
</body>
</html>
21 changes: 21 additions & 0 deletions core/src/components/modal/test/custom-dialog/modal.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';

test.describe('modal: custom dialog', () => {
test('should size custom modal correctly', async ({ page }, testInfo) => {
test.skip(testInfo.project.metadata.rtl === true, 'This does not test LTR vs. RTL layout.');
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/ionic-team/ionic-framework/issues/24080',
});

await page.goto('/src/components/modal/test/custom-dialog');
const ionModalDidPresent = await page.spyOnEvent('ionModalDidPresent');

await page.click('#custom-modal');

await ionModalDidPresent.next();

expect(await page.screenshot()).toMatchSnapshot(`modal-custom-dialog-${page.getSnapshotSettings()}.png`);
});
});
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.
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.
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.
16 changes: 16 additions & 0 deletions core/src/css/core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,22 @@ html.ios ion-modal.modal-card .ion-page {
z-index: $z-index-page-container;
}

/**
* When making custom dialogs, using
* ion-content is not required. As a result,
* some developers may wish to have dialogs
* that are automatically sized by the browser.
* These changes allow certain dimension values
* such as fit-content to work correctly.
*/
ion-modal .ion-page {
position: relative;

contain: layout style;

height: 100%;
}

.split-pane-visible > .ion-page.split-pane-main {
position: relative;
}
Expand Down