Skip to content

Commit

Permalink
fix(dialog): Apply max-width to same element as min-width (#3749)
Browse files Browse the repository at this point in the history
  • Loading branch information
kfranqueiro authored Oct 16, 2018
1 parent b6cf04e commit 2dac7e1
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/mdc-dialog/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
@mixin mdc-dialog-max-width($max-width, $margin) {
$max-size-calc-expr: calc(100vw - #{$margin * 2});

.mdc-dialog__container {
.mdc-dialog__surface {
@if $max-width {
$max-width-breakpoint: $max-width + ($margin * 2);

Expand Down
1 change: 1 addition & 0 deletions packages/mdc-dialog/mdc-dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
.mdc-dialog__container {
display: flex;
flex-direction: row; // IE 11
justify-content: space-around; // Ensure Safari centers the dialog (because it treats the container's width oddly)
box-sizing: border-box;
transform: scale(.8);
opacity: 0;
Expand Down
8 changes: 8 additions & 0 deletions test/screenshot/golden.json
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,14 @@
"desktop_windows_ie@11": "https://storage.googleapis.com/mdc-web-screenshot-tests/advorak/2018/09/21/16_50_45_748/spec/mdc-dialog/classes/overflow-top.html.windows_ie_11.png"
}
},
"spec/mdc-dialog/issues/3717.html": {
"public_url": "https://storage.googleapis.com/mdc-web-screenshot-tests/travis/2018/10/15/14_47_38_876/spec/mdc-dialog/issues/3717.html?utm_source=golden_json",
"screenshots": {
"desktop_windows_chrome@latest": "https://storage.googleapis.com/mdc-web-screenshot-tests/travis/2018/10/15/14_47_38_876/spec/mdc-dialog/issues/3717.html.windows_chrome_69.png",
"desktop_windows_firefox@latest": "https://storage.googleapis.com/mdc-web-screenshot-tests/travis/2018/10/15/14_47_38_876/spec/mdc-dialog/issues/3717.html.windows_firefox_62.png",
"desktop_windows_ie@11": "https://storage.googleapis.com/mdc-web-screenshot-tests/travis/2018/10/15/14_47_38_876/spec/mdc-dialog/issues/3717.html.windows_ie_11.png"
}
},
"spec/mdc-dialog/mixins/container-fill-color.html": {
"public_url": "https://storage.googleapis.com/mdc-web-screenshot-tests/advorak/2018/09/21/23_10_20_654/spec/mdc-dialog/mixins/container-fill-color.html?utm_source=golden_json",
"screenshots": {
Expand Down
5 changes: 5 additions & 0 deletions test/screenshot/spec/mdc-dialog/fixture.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ $custom-dialog-color: $material-color-red-300;
.test-dialog--max-height {
@include mdc-dialog-max-height(400px, 30px);
}

.test-dialog--3717 {
@include mdc-dialog-min-width(600px);
@include mdc-dialog-max-width(300px, 30px);
}
98 changes: 98 additions & 0 deletions test/screenshot/spec/mdc-dialog/issues/3717.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<!DOCTYPE html>
<!--
Copyright 2018 Google Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue #3717 - MDC Web Screenshot Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../../out/mdc.button.css">
<link rel="stylesheet" href="../../../out/mdc.dialog.css">
<link rel="stylesheet" href="../../../out/mdc.form-field.css">
<link rel="stylesheet" href="../../../out/mdc.list.css">
<link rel="stylesheet" href="../../../out/mdc.radio.css">
<link rel="stylesheet" href="../../../out/spec/fixture.css">
<link rel="stylesheet" href="../../../out/spec/mdc-dialog/fixture.css">
</head>

<body class="test-container test-container--edge-fonts mdc-dialog-scroll-lock">
<main class="test-viewport test-viewport--center">

<button class="test-dialog-open-button" data-test-dialog-id="test-dialog" autofocus>Open Dialog</button>

<!--
This page tests invoking mdc-dialog's min-width mixin with a higher value than the max-width mixin.
https://github.com/material-components/material-components-web/issues/3717
-->
<div class="mdc-dialog mdc-dialog--open test-dialog test-dialog--3717"
role="alertdialog"
aria-modal="true"
aria-labelledby="test-dialog__title"
aria-describedby="test-dialog__content"
id="test-dialog">
<div class="mdc-dialog__scrim"></div>
<div class="mdc-dialog__container">
<div class="mdc-dialog__surface">
<h2 class="mdc-dialog__title test-dialog__title test-dialog__title--3-line" id="test-dialog__title"><!--
-->“The Count of Monte Cristo” by Alexandre <span class="test-font--redact-all">Dumas</span>.<br>
Published in 1844 and translated by Robin Buss.<br>
Public domain.<!--
--></h2>
<div class="mdc-dialog__content test-dialog__content" id="test-dialog__content">
<div class="test-dialog__content-rect">
<p>On the <span class="test-font--redact-all">24th</span> of February, 1815, the look-out at Notre-Dame de la Garde
signalled the <span class="test-font--redact-all">three-master, the</span> Pharaon from Smyrna, Trieste, and
Naples.</p>

<p>As usual, a pilot put off immediately, and rounding the Château d’If,
got on board the vessel between Cape Morgiou and Rion island.</p>

<p>Immediately, and according to custom, the ramparts of Fort Saint-Jean
were covered with spectators; it is always an event at Marseilles for a
ship to come into port, especially when this ship, like the Pharaon, has
been built, rigged, and laden at the old Phocee docks, and belongs to an
owner of the city.</p>
</div>
</div>
<footer class="mdc-dialog__actions">
<button type="button" class="mdc-button mdc-dialog__button" data-mdc-dialog-action="close">
<span class="test-font--redact-all">Cancel</span>
</button>
<button type="button" class="mdc-button mdc-dialog__button" data-mdc-dialog-action="yes">
<span class="test-font--redact-all">OK</span>
</button>
</footer>
</div>
</div>
</div>

</main>

<!-- Automatically provides/replaces `Promise` if missing or broken. -->
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.js"></script>
<script src="https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fontfaceobserver/2.0.13/fontfaceobserver.standalone.js"></script>
<script src="../../../out/material-components-web.js"></script>
<script src="../../../out/spec/fixture.js"></script>
<script src="../../../out/spec/mdc-dialog/fixture.js"></script>
</body>
</html>

0 comments on commit 2dac7e1

Please sign in to comment.