Skip to content

Update to fix CCP locale switching#1342

Open
cocomarine wants to merge 5 commits intomainfrom
hj/testing-locale-switch-3
Open

Update to fix CCP locale switching#1342
cocomarine wants to merge 5 commits intomainfrom
hj/testing-locale-switch-3

Conversation

@cocomarine
Copy link
Contributor

@cocomarine cocomarine commented Feb 25, 2026

Changes

Locale switching fix

Initial load problem fix

  • Before: when an editor page with locales other than en was first loaded in CCP, it rendered en page rather than the locale page (editor-standalone was fine)
  • Updated to make sure initial attributes like locale are passed to React by reading them from the DOM in reactProps() of web-component.js
    • This is so that the first render uses the host's value even when attributeChangedCallback hasn't been run yet

Copilot AI review requested due to automatic review settings February 25, 2026 14:51
@cocomarine cocomarine temporarily deployed to previews/1342/merge February 25, 2026 14:52 — with GitHub Actions Inactive
Copy link
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

This PR updates the project-loading hook to make localStorage cache usage dependent on the active i18n locale, aiming to prevent incorrect cached content from being loaded after CCP locale switching.

Changes:

  • Adds a locale match check (cachedProject?._cachedLocale === i18n.language) before loading a cached project.
  • Simplifies the cache eligibility logic into a single shouldUseCache condition.

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

@cocomarine cocomarine temporarily deployed to previews/1342/merge February 25, 2026 15:21 — with GitHub Actions Inactive
@cocomarine cocomarine temporarily deployed to previews/1342/merge February 25, 2026 15:43 — with GitHub Actions Inactive
@cocomarine cocomarine temporarily deployed to previews/1342/merge February 26, 2026 08:10 — with GitHub Actions Inactive
Comment on lines +169 to +170
const raw = this.getAttribute(name);
if (raw != null)
Copy link
Contributor

@zetter-rpf zetter-rpf Feb 26, 2026

Choose a reason for hiding this comment

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

Looking at examples of other custom components (such as the one here ) it looks like a common pattern is to use hasAttribute. The benefit of using this is we might be able to remove the (raw != null) check here and also the new if (rawValue == null || rawValue === "") return rawValue; check in parseAttribute (since there could be a reasons you might want to set an attribute to ""?). For example:

 if (this.hasAttribute(name)) {
   const raw = this.getAttribute(name);
   fromDom[camelCase(name)] = this.parseAttribute(name, raw);
}

@zetter-rpf
Copy link
Contributor

This is a temporary fix as it effectively disabled caching.

For my understanding, do you mean this disables the project caching when you change locale? Or is it more than that?

Copy link
Contributor

@zetter-rpf zetter-rpf left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, the approach looks good. Let me know when you have fixed the tests and I can re-review.

It would be good to have at least one new test for the updated behaviour of useProject

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