switches to a portal architecture for fake fullscreen div - #14292
Open
HarveyPeachey wants to merge 1 commit into
Open
switches to a portal architecture for fake fullscreen div#14292HarveyPeachey wants to merge 1 commit into
HarveyPeachey wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates MediaLoader’s “fake fullscreen” implementation to use a portal-based backdrop layer rendered at the document root, addressing stacking-context issues (notably on iOS Safari) while keeping the elevated player wrapper above the backdrop.
Changes:
- Introduces
FakeFullscreenLayer, which portals the fullscreen backdrop<div>todocument.bodyafter mount to avoid hydration mismatches. - Introduces
FakeFullscreenStyles, which injects the shared fake-fullscreen CSS intodocument.headonce per page (guarded by a fixed style element id) and applies the CSP nonce when provided. - Replaces the previous in-tree backdrop
<div>andHelmet-injected<style>with the new portal/style-injection approach.
Suppressed comments (1)
src/app/components/MediaLoader/index.tsx:80
- FakeFullscreenLayer now portals the backdrop into document.body, which is a significant DOM-structure change from the previous in-tree backdrop. Please add a test to assert the backdrop element is rendered under document.body (not within the MediaLoader container) and that toggling fake fullscreen adds/removes the active class as expected.
const FakeFullscreenLayer = ({ isActive }: { isActive: boolean }) => {
// Defer the portal until after mount so the hydration render matches the
// server (both render nothing). Portalling during hydration would insert the
// backdrop into <body> before hydration completes, causing a mismatch.
const [isMounted, setIsMounted] = useState(false);
Comment on lines
+57
to
+61
| const FakeFullscreenStyles = ({ nonce }: { nonce?: string | null }) => { | ||
| useEffect(() => { | ||
| if (document.getElementById(FAKE_FULLSCREEN_STYLE_ID)) return; | ||
|
|
||
| const styleElement = document.createElement('style'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves JIRA:
Summary
A very high-level summary of easily-reproducible changes that can be understood by non-devs, and why these changes where made.
Code changes
Testing
Useful Links