Skip to content

Commit

Permalink
Fix backdrop color for <dialog popup>
Browse files Browse the repository at this point in the history
When a `<dialog>` is opened via `.showPopUp()`, it should have
a completely transparent ::backdrop. This CL fixes that by adding
a special case for dialog::open.

See also:
openui/open-ui#561 (comment)

Bug: 1307772
Change-Id: I444730c57c699f4af4a708cc316dd81aa7563669
  • Loading branch information
mfreed7 authored and chromium-wpt-export-bot committed Oct 4, 2022
1 parent c5aa57c commit 7167621
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
33 changes: 33 additions & 0 deletions html/semantics/popups/popup-dialog-appearance-ref.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Dialog-Popup appearance</title>
<link rel="author" href="mailto:masonf@chromium.org">

<p>Both dialogs should have the same shades of background.</p>
<p>The pop-up should have a completely-transparent ::backdrop.</p>
<dialog popup id=d1>This is a modal dialog</dialog>
<dialog popup id=d2>This is a dialog pop-up</dialog>

<style>
dialog {
left: 50px;
right: auto;
bottom: auto;
}
#d1 {top:100px;}
#d2 {top:150px;}
/* Force backdrop to spec: */
#d1::backdrop {
/* https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3 */
background-color: rgba(0, 0, 0, 0.1);
}
#d2::backdrop {
/* When shown as a pop-up, backdrop must be transparent */
background-color: transparent;
}
</style>

<script>
document.getElementById('d1').showModal();
document.getElementById('d2').showPopUp();
</script>
26 changes: 26 additions & 0 deletions html/semantics/popups/popup-dialog-appearance.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Dialog-Popup appearance</title>
<link rel="author" href="mailto:masonf@chromium.org">
<link rel=help href="https://open-ui.org/components/popup.research.explainer">
<link rel="match" href="popup-dialog-appearance-ref.tentative.html">

<p>Both dialogs should have the same shades of background.</p>
<p>The pop-up should have a completely-transparent ::backdrop.</p>
<dialog popup id=d1>This is a modal dialog</dialog>
<dialog popup id=d2>This is a dialog pop-up</dialog>

<style>
dialog {
left: 50px;
right: auto;
bottom: auto;
}
#d1 {top:100px;}
#d2 {top:150px;}
</style>

<script>
document.getElementById('d1').showModal();
document.getElementById('d2').showPopUp();
</script>

0 comments on commit 7167621

Please sign in to comment.