Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix loading of video tag in Firefox

Oliver Günther16768c2f2b33
diff --git a/app/components/onboarding/video_dialog_component.html.erb b/app/components/onboarding/video_dialog_component.html.erb
index 083533cc895..7d8a2d81d2a 100644
--- a/app/components/onboarding/video_dialog_component.html.erb
+++ b/app/components/onboarding/video_dialog_component.html.erb
@@ -21,15 +21,22 @@
Primer::BaseComponent.new(
my: 2,
tag: :video,
- frameborder: "0",
height: "430",
width: "100%",
- autoplay: "autoplay",
controls: true,
- src: video_src,
- allowfullscreen: true
+ preload: "none",
+ allowfullscreen: true,
+ data: { "media-dialog-target": "video" }
)
- )
+ ) do
+ render(
+ Primer::BaseComponent.new(
+ tag: :source,
+ src: video_src,
+ type: "video/mp4"
+ )
+ )
+ end
end
)
end
diff --git a/frontend/src/stimulus/controllers/dynamic/media-dialog.controller.ts b/frontend/src/stimulus/controllers/dynamic/media-dialog.controller.ts
index be05628f747..b3c7ae6cebf 100644
--- a/frontend/src/stimulus/controllers/dynamic/media-dialog.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/media-dialog.controller.ts
@@ -31,13 +31,27 @@
import { Controller } from '@hotwired/stimulus';
export default class MediaDialogController extends Controller<HTMLDialogElement> {
+ static targets = ['video'];
+
+ declare readonly videoTarget:HTMLVideoElement;
+
+ videoTargetConnected(target:HTMLVideoElement) {
+ // Wait for next frame to ensure dialog is fully rendered
+ requestAnimationFrame(() => {
+ // Add error handling for Firefox codec issues
+ target.addEventListener('error', (event) => {
+ console.error('Video failed to load in dialog context:', event);
+ });
+
+ // Force reload the video source to work around Firefox dialog issues
+ target.load();
+ });
+ }
+
connect() {
// Remove the video element on close to prevent background play
this.element.addEventListener('close', () => {
- this
- .element
- .querySelectorAll('iframe,video,embed')
- .forEach(el => el.remove());
+ this.element.querySelectorAll('video').forEach(el => el.remove());
});
}
}