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
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3933277
Auto-Submit: Mason Freed <masonf@chromium.org>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1054947}
NOKEYCHECK=True
GitOrigin-RevId: 4c1740d3237061fd2c84bad3fe9179d3fa345e9d
  • Loading branch information
mfreed7 authored and copybara-github committed Oct 5, 2022
1 parent 57448e6 commit bbf2233
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
4 changes: 3 additions & 1 deletion blink/renderer/core/css/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
background-color: Canvas;
}

[popup]::backdrop {
[popup]:open::backdrop {
/* From the (modified) fullscreen spec: https://fullscreen.spec.whatwg.org/#user-agent-level-style-sheet-defaults: */
position: fixed;
inset: 0;
/* Specific to [popup]: */
pointer-events: none !important;
/* https://github.com/openui/open-ui/issues/561#issuecomment-1242297093 */
background-color: transparent;
}
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>
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 bbf2233

Please sign in to comment.