Skip to content
Draft
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
18 changes: 18 additions & 0 deletions components/backdrop/backdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import '../colors/colors.js';
import { css, html, LitElement } from 'lit';
import { cssEscape, getComposedChildren, getComposedParent, isComposedAncestor, isVisible } from '../../helpers/dom.js';
import { getComposedActiveElement } from '../../helpers/focus.js';
import { getFlag } from '../../helpers/flags.js';

const tabIndexSolution = getFlag('tabIndexSolution');

const BACKDROP_HIDDEN = 'data-d2l-backdrop-hidden';
const BACKDROP_ARIA_HIDDEN = 'data-d2l-backdrop-aria-hidden';
const BACKDROP_INERT = 'data-d2l-backdrop-inert';
const TRANSITION_DURATION = 200;

const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
Expand Down Expand Up @@ -173,6 +177,13 @@ function hideAccessible(target) {
child.setAttribute(BACKDROP_ARIA_HIDDEN, child.getAttribute('aria-hidden'));
}
child.setAttribute('aria-hidden', 'true');
if (tabIndexSolution) {
if (child.hasAttribute('inert')) {
child.setAttribute(BACKDROP_INERT, '');
}
child.setAttribute('inert', '');
}


child.setAttribute(BACKDROP_HIDDEN, BACKDROP_HIDDEN);
hiddenElements.push(child);
Expand Down Expand Up @@ -201,6 +212,13 @@ function showAccessible(elems) {
} else {
elem.removeAttribute('aria-hidden');
}
if (tabIndexSolution) {
if (elem.hasAttribute(BACKDROP_INERT)) {
elem.removeAttribute(BACKDROP_INERT);
} else {
elem.removeAttribute('inert');
}
}
elem.removeAttribute(BACKDROP_HIDDEN);
}
}
Expand Down
30 changes: 30 additions & 0 deletions components/dialog/demo/dialog-iframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<link rel="stylesheet" href="../../demo/styles.css" type="text/css">
<script type="module">
import '../../demo/demo-page.js';
</script>
</head>
<body unresolved>
<d2l-demo-page page-title="d2l-dialog">

<h2>Fullscreen Demo (iframe)</h2>
<p> After opening the dialog, click here and then start tabbing.</p>

<d2l-demo-snippet full-width>
<template>
<iframe style="border: none; display: block; height: 400px; width: 100%;"></iframe>
</template>
<script type="module">
import { getFlag } from '../../../helpers/flags.js';
document.querySelector('iframe').src = './iframes/outer-frame.html?demo-flag-tabIndexSolution=' + getFlag('tabIndexSolution');
</script>
</d2l-demo-snippet>


</d2l-demo-page>
</body>
</html>
25 changes: 25 additions & 0 deletions components/dialog/demo/iframes/opener-frame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<link rel="stylesheet" href="../../../demo/styles.css" type="text/css">
<script type="module">
import '../../../demo/demo-page.js';
import '../../../button/button.js';
</script>
</head>
<body unresolved>
<d2l-button id="open">Open Dialog from Inner Frame</d2l-button>
<d2l-button>Other</d2l-button>
<d2l-button>Other</d2l-button>
<d2l-button>Other</d2l-button>
<script>
requestAnimationFrame((() => {
document.querySelector('#open').addEventListener('click', () => {
parent.OpenFullscreenDialog();
});
}));
</script>
</body>
</html>
39 changes: 39 additions & 0 deletions components/dialog/demo/iframes/outer-frame.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<link rel="stylesheet" href="../../../demo/styles.css" type="text/css">
<script type="module">
import '../../../demo/demo-page.js';
import '../../../button/button.js';
import '../../dialog-fullscreen.js';

window.OpenFullscreenDialog = function() {
const dialog = window.document.querySelector('#dialogFullscreen');
dialog.opened = true;
};
</script>
</head>
<body unresolved>
<!-- <button></button> Uncomment and it will be fixed -->
<div>
<iframe style="border: none; display: block; height: 400px; width: 100%;"></iframe>
</div>
<d2l-dialog-fullscreen id="dialogFullscreen" title-text="Fullscreen Title">
<p>Deadlights jack lad schooner scallywag dance the hempen jig carouser broadside cable strike colors. Bring a spring upon her cable holystone blow the man down spanker</p>
<p>Shiver me timbers to go on account lookout wherry doubloon chase. Belay yo-ho-ho keelhaul squiffy black spot yardarm spyglass sheet transom heave to.</p>
<p>Trysail Sail ho Corsair red ensign hulk smartly boom jib rum gangway. Case shot Shiver me timbers gangplank crack Jennys tea cup ballast Blimey lee snow crow's nest rutters. Fluke jib scourge of the seven seas boatswain schooner gaff booty Jack Tar transom spirits.</p>
<p>Deadlights jack lad schooner scallywag dance the hempen jig carouser broadside cable strike colors. Bring a spring upon her cable holystone blow the man down spanker</p>
<p>Shiver me timbers to go on account lookout wherry doubloon chase. Belay yo-ho-ho keelhaul squiffy black spot yardarm spyglass sheet transom heave to.</p>
<p>Trysail Sail ho Corsair red ensign hulk smartly boom jib rum gangway. Case shot Shiver me timbers gangplank crack Jennys tea cup ballast Blimey lee snow crow's nest rutters. Fluke jib scourge of the seven seas boatswain schooner gaff booty Jack Tar transom spirits.</p>
<d2l-button>Button</d2l-button>
<d2l-button slot="footer" primary data-dialog-action="save">Save</d2l-button>
<d2l-button slot="footer" data-dialog-action>Cancel</d2l-button>
</d2l-dialog-fullscreen>
<script type="module">
import { getFlag } from '../../../../helpers/flags.js';
document.querySelector('iframe').src = 'opener-frame.html?demo-flag-tabIndexSolution=' + getFlag('tabIndexSolution');
</script>
</body>
</html>
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ <h2 class="d2l-heading-3">Components</h2>
<li>
Dialogs
<ul>
<li><a href="components/dialog/demo/dialog-iframe.html">d2l-dialog (with iframes)</a></li>
<li><a href="components/dialog/demo/dialog.html">d2l-dialog</a></li>
<li><a href="components/dialog/demo/dialog-nested.html">d2l-dialog (Nested)</a></li>
<li><a href="components/dialog/demo/dialog-confirm.html">d2l-dialog-confirm</a></li>
Expand Down