-
Notifications
You must be signed in to change notification settings - Fork 125
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
Popover Menu Not Loading Correctly Inside Shadow DOM #1319
Comments
Thanks, I'll look into it! |
This comment was marked as off-topic.
This comment was marked as off-topic.
@mihar-22 Seems like the issue was on my end, trying to call DOM elements the wrong way. Was solved by adding a container within the modal element with id @query('#menu-container')
private accessor menuContainerElement: HTMLElement | null = null; which makes it so this works just fine: layout: new VidstackPlayerLayout({
...defaultVidstackLayout,
menuContainer: this.menuContainerElement,
}), |
A new issue did arrive now though, only the settings and chapters container pop up like they should. But all nested containers don't (playback speed, audio settings, etc.)... Schermopname.van.2024-06-20.12-17-17.webm |
You'll need to provide me a reproduction because this is working in my testing. Closing until one is provided, thanks! |
@mihar-22 Could you reopen the issue? I've created a simple recreation of the issue by simulating the way components are loaded within the shadow DOM. As can be seen, when a modal is loaded within a shadow DOM, issues arise. Below is the reproduction. Reproduction<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Video Player Modal Example</title>
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
</head>
<body>
<main>
<button id="openButton">Open Video Modal</button>
<foo-element></foo-element>
</main>
<script type="module">
class FooElement extends HTMLElement {
constructor() {
super();
const shadow = this.attachShadow({ mode: "open" });
// External stylesheets within shadow DOM
const themeLink = document.createElement("link");
themeLink.setAttribute("rel", "stylesheet");
themeLink.setAttribute("href", "https://cdn.vidstack.io/player/theme.css");
shadow.appendChild(themeLink);
const videoLink = document.createElement("link");
videoLink.setAttribute("rel", "stylesheet");
videoLink.setAttribute("href", "https://cdn.vidstack.io/player/video.css");
shadow.appendChild(videoLink);
const dialog = document.createElement("dialog");
dialog.id = "videoModal";
const video = document.createElement("div");
video.id = "videoPlayer";
const menu = document.createElement("div");
menu.id = "menuContainer";
dialog.appendChild(video);
dialog.appendChild(menu);
shadow.appendChild(dialog);
}
}
customElements.define("foo-element", FooElement);
</script>
<script type="module">
import { VidstackPlayer, VidstackPlayerLayout } from 'https://cdn.vidstack.io/player';
document.addEventListener('DOMContentLoaded', () => {
const openButton = document.getElementById('openButton');
const fooElement = document.querySelector('foo-element');
openButton.addEventListener('click', async () => {
const shadow = fooElement.shadowRoot;
const videoModal = shadow.getElementById('videoModal');
const videoPlayerContainer = shadow.getElementById('videoPlayer');
const menuContainer = shadow.getElementById('menuContainer');
videoModal.showModal();
const player = await VidstackPlayer.create({
target: videoPlayerContainer,
src: 'https://files.vidstack.io/sprite-fight/720p.mp4',
viewType: 'video',
streamType: 'on-demand',
logLevel: 'warn',
crossOrigin: true,
playsInline: true,
title: 'Sprite Fight',
poster: 'https://files.vidstack.io/sprite-fight/poster.webp',
layout: new VidstackPlayerLayout({
thumbnails: 'https://files.vidstack.io/sprite-fight/thumbnails.vtt',
menuContainer: menuContainer,
}),
tracks: [
{
src: 'https://files.vidstack.io/sprite-fight/subs/english.vtt',
label: 'English',
language: 'en-US',
kind: 'subtitles',
type: 'vtt',
default: true,
},
{
src: 'https://files.vidstack.io/sprite-fight/subs/spanish.vtt',
label: 'Spanish',
language: 'es-ES',
kind: 'subtitles',
type: 'vtt',
},
{
src: 'https://files.vidstack.io/sprite-fight/chapters.vtt',
language: 'en-US',
kind: 'chapters',
type: 'vtt',
default: true,
},
],
});
videoModal.addEventListener('close', () => {
videoPlayerContainer.innerHTML = '';
});
});
});
</script>
</body>
</html> |
@mihar-22 Just checking in, any chance the issue could be reopened? Can't do it myself. |
Thanks for the repro @taran2k, found the issue and I'll release the fix some time today or tomorrow. |
Thanks for the issue and the solution! We are seeing the similar thingy with |
Current Behavior:
The newly added menuContainer property is being ignored, and popovers are still added as the latest div element instead of being within the scope of the provided menuContainer element, making it so that the chapters popover as well as the settings popover are unusable when a video is being played inside a modal using the HTMLDialogElement API.
Expected Behavior:
Expected behaviour is for the given menuContainer element to be the container inside which the chapters and settings menu render.
Steps To Reproduce:
Environment:
Video Reconstruction
Schermopname.van.2024-06-20.08-22-55.webm
The text was updated successfully, but these errors were encountered: