diff --git a/projects/packages/videopress/changelog/fix-vidp-245-upgradetrigger-base-ui-crash b/projects/packages/videopress/changelog/fix-vidp-245-upgradetrigger-base-ui-crash new file mode 100644 index 000000000000..fb278af93a12 --- /dev/null +++ b/projects/packages/videopress/changelog/fix-vidp-245-upgradetrigger-base-ui-crash @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix admin page crash on video upload/delete when the free-plan upgrade nudge is shown diff --git a/projects/packages/videopress/src/client/admin/components/admin-page/index.tsx b/projects/packages/videopress/src/client/admin/components/admin-page/index.tsx index ea63b60545ec..ebe083924eb0 100644 --- a/projects/packages/videopress/src/client/admin/components/admin-page/index.tsx +++ b/projects/packages/videopress/src/client/admin/components/admin-page/index.tsx @@ -211,6 +211,19 @@ const Admin = () => { export default Admin; +// VIDP-245: keep these `__()` calls at module scope as separate statements. +// If they live as the two arms of an inline ternary, terser folds them into a +// single `__( cond ? 'a' : 'b', domain )`, which breaks string-literal POT +// extraction (the i18n-check-webpack-plugin fails the production build). +const UPGRADE_TRIGGER_USED_VIDEO_TEXT = __( + 'You have used your free video upload', + 'jetpack-videopress-pkg' +); +const UPGRADE_TRIGGER_FREE_PLAN_TEXT = __( + 'The free plan includes one video upload.', + 'jetpack-videopress-pkg' +); + const UpgradeTrigger = ( { hasUsedVideo = false }: { hasUsedVideo: boolean } ) => { const { adminUri, siteSuffix } = window.jetpackVideoPressInitialState; @@ -236,9 +249,18 @@ const UpgradeTrigger = ( { hasUsedVideo = false }: { hasUsedVideo: boolean } ) = run ); + // VIDP-245: keep the `Notice.Root` children shape invariant across the + // `hasUsedVideo` flip. base-ui@1.4.1's `useRenderElement` swaps between two + // different ref-merge hooks depending on subtree shape, so conditionally + // mounting `` (as this did before) misaligns its stored + // fork-ref and crashes on the next upload/delete. Always render the + // Description — mirroring the modern dashboard's `free-tier-notice.tsx` — + // varying only its text, with a non-empty fallback nudge before the first + // upload so we never render an empty styled row. The two strings are hoisted + // to module scope (above) to avoid the terser i18n ternary-fold. const description = hasUsedVideo - ? __( 'You have used your free video upload', 'jetpack-videopress-pkg' ) - : ''; + ? UPGRADE_TRIGGER_USED_VIDEO_TEXT + : UPGRADE_TRIGGER_FREE_PLAN_TEXT; const cta = __( 'Upgrade now to unlock unlimited videos, 1TB of storage, and more!', @@ -247,7 +269,7 @@ const UpgradeTrigger = ( { hasUsedVideo = false }: { hasUsedVideo: boolean } ) = return ( - { description && { description } } + { description } { cta } diff --git a/projects/plugins/jetpack/changelog/fix-vidp-245-upgradetrigger-base-ui-crash b/projects/plugins/jetpack/changelog/fix-vidp-245-upgradetrigger-base-ui-crash new file mode 100644 index 000000000000..8e717ff646f3 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-vidp-245-upgradetrigger-base-ui-crash @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +VideoPress: fix admin page crash on video upload/delete when the free-plan upgrade nudge is shown diff --git a/projects/plugins/videopress/changelog/fix-vidp-245-upgradetrigger-base-ui-crash b/projects/plugins/videopress/changelog/fix-vidp-245-upgradetrigger-base-ui-crash new file mode 100644 index 000000000000..fb278af93a12 --- /dev/null +++ b/projects/plugins/videopress/changelog/fix-vidp-245-upgradetrigger-base-ui-crash @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix admin page crash on video upload/delete when the free-plan upgrade nudge is shown