Skip to content

New tab preview for html project works with locales different to en#1458

Merged
abcampo-iry merged 1 commit into
mainfrom
issues/1322-preview-new-tab-for-html-project-works-for-other-locales
May 11, 2026
Merged

New tab preview for html project works with locales different to en#1458
abcampo-iry merged 1 commit into
mainfrom
issues/1322-preview-new-tab-for-html-project-works-for-other-locales

Conversation

@abcampo-iry
Copy link
Copy Markdown
Contributor

@abcampo-iry abcampo-iry commented May 7, 2026

closes: 1322

Fixes HTML “Preview in new tab” for unsaved projects opened in localized routes such as en-US.

Unsaved starter projects are cached locally with their source locale, often en.
The browser preview route uses the current URL locale, for example en-US, so the cached unsaved project was rejected and the preview loaded a fresh blank starter instead.

This change lets browserPreview=true loads use the matching cached project even when the cached locale differs from the route locale.

Update from copilot comment: the ?browserPreview=true cache bypass is now scoped to embedded previews only.

WebComponentLoader passes its existing embedded prop into useProject, so normal editor routes with ?browserPreview=true still require the cached project locale to match. Embedded preview tabs can still load unsaved cached changes across locale fallbacks, which preserves the original fix.

I've checked the other repos and we are effectively passing the prop and tested so we should be good.

Screen.Recording.2026-05-07.at.17.57.26.mov

@abcampo-iry abcampo-iry temporarily deployed to previews/1458/merge May 7, 2026 15:06 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry marked this pull request as ready for review May 8, 2026 07:07
Copilot AI review requested due to automatic review settings May 8, 2026 07:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes HTML “Preview in new tab” for unsaved starter projects opened under localized routes (e.g., en-US) by allowing browser-preview loads to reuse the locally cached project even when the cached project’s locale differs from the route locale.

Changes:

  • Update useProject cache-loading rules to treat browserPreview=true (from Redux state or query string) as a signal to load cached projects even when locales don’t match.
  • Add a regression test ensuring embedded browser preview uses the cached project despite a locale mismatch.
  • Reset window.history in embedded tests to avoid query-string leakage across tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/hooks/useProject.js Adjusts cache eligibility and locale-matching logic for browser preview loads.
src/hooks/useProject.test.js Adds coverage for embedded browser preview with locale mismatch and resets URL state after tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/hooks/useProject.js Outdated
@abcampo-iry abcampo-iry marked this pull request as draft May 8, 2026 07:11
@abcampo-iry abcampo-iry temporarily deployed to previews/1458/merge May 8, 2026 08:20 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry force-pushed the issues/1322-preview-new-tab-for-html-project-works-for-other-locales branch from cafc68e to 668a8b5 Compare May 8, 2026 08:53
@abcampo-iry abcampo-iry temporarily deployed to previews/1458/merge May 8, 2026 08:53 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry marked this pull request as ready for review May 8, 2026 09:01
@abcampo-iry abcampo-iry requested a review from Copilot May 8, 2026 09:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/hooks/useProject.js Outdated
Comment thread src/containers/WebComponentLoader.test.js
@abcampo-iry abcampo-iry force-pushed the issues/1322-preview-new-tab-for-html-project-works-for-other-locales branch from 668a8b5 to ffa36a2 Compare May 8, 2026 09:48
@abcampo-iry abcampo-iry temporarily deployed to previews/1458/merge May 8, 2026 09:48 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry force-pushed the issues/1322-preview-new-tab-for-html-project-works-for-other-locales branch from ffa36a2 to 6963ca2 Compare May 8, 2026 09:54
@abcampo-iry abcampo-iry temporarily deployed to previews/1458/merge May 8, 2026 09:54 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry requested a review from Copilot May 8, 2026 09:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/hooks/useProject.test.js Outdated
Comment thread src/hooks/useProject.test.js
@abcampo-iry abcampo-iry temporarily deployed to previews/1458/merge May 8, 2026 11:49 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry force-pushed the issues/1322-preview-new-tab-for-html-project-works-for-other-locales branch from f89e2c6 to 35f46e7 Compare May 8, 2026 11:51
@abcampo-iry abcampo-iry temporarily deployed to previews/1458/merge May 8, 2026 11:51 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry requested a review from Copilot May 8, 2026 11:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/hooks/useProject.test.js Outdated
@abcampo-iry abcampo-iry force-pushed the issues/1322-preview-new-tab-for-html-project-works-for-other-locales branch from 35f46e7 to 4d9c81e Compare May 8, 2026 12:08
@abcampo-iry abcampo-iry temporarily deployed to previews/1458/merge May 8, 2026 12:09 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry requested a review from Copilot May 8, 2026 12:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@abcampo-iry abcampo-iry marked this pull request as draft May 8, 2026 14:13
@abcampo-iry abcampo-iry force-pushed the issues/1322-preview-new-tab-for-html-project-works-for-other-locales branch from 4d9c81e to 394a385 Compare May 8, 2026 14:16
@abcampo-iry abcampo-iry temporarily deployed to previews/1458/merge May 8, 2026 14:16 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry force-pushed the issues/1322-preview-new-tab-for-html-project-works-for-other-locales branch from 394a385 to 9473c69 Compare May 8, 2026 14:19
@abcampo-iry abcampo-iry marked this pull request as ready for review May 8, 2026 14:19
@abcampo-iry abcampo-iry temporarily deployed to previews/1458/merge May 8, 2026 14:19 — with GitHub Actions Inactive
@abcampo-iry abcampo-iry force-pushed the issues/1322-preview-new-tab-for-html-project-works-for-other-locales branch from 9473c69 to 62e9809 Compare May 8, 2026 15:28
@abcampo-iry abcampo-iry changed the title New tab for html project works for other locales New tab preview for html project works with locales different to en May 8, 2026
Copy link
Copy Markdown
Contributor

@mwtrew mwtrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@abcampo-iry abcampo-iry merged commit 168c78f into main May 11, 2026
7 checks passed
@abcampo-iry abcampo-iry deleted the issues/1322-preview-new-tab-for-html-project-works-for-other-locales branch May 11, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants