Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[open-formulieren/open-forms#4600] Language switch now triggers an page reload #715

Merged

Conversation

robinmolen
Copy link
Contributor

This is to make sure that all language elements will be translated to the newly selected language

@robinmolen robinmolen added the needs-backport Fix must be backported to stable release branch label Sep 25, 2024
Copy link

codecov bot commented Sep 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.64%. Comparing base (2633c1f) to head (10a1ea4).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #715      +/-   ##
==========================================
+ Coverage   77.27%   77.64%   +0.37%     
==========================================
  Files         233      233              
  Lines        4752     4773      +21     
  Branches     1283     1300      +17     
==========================================
+ Hits         3672     3706      +34     
+ Misses       1047     1034      -13     
  Partials       33       33              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/sdk.js Outdated
@@ -173,8 +173,7 @@ class OpenForm {
}

async onLanguageChangeDone(newLanguagecode) {
this.formObject = await get(this.url);
this.render();
window.location.reload();
Copy link
Member

Choose a reason for hiding this comment

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

unfortunately this approach is too naive - we can only trigger this in the backend project where we know what the full page looks like, but on pages (like a CMS) outside of our control where the form is embedded, we must play nice and not take over control of the whole page.

I think adding an option to accept a callback to invoke when the language change is done/requested is the best approach, so that anyone who wishes to can hook into this to do the necessary thing.

@robinmolen
Copy link
Contributor Author

TODO in SDK:

  • Add an property onLanguageChange that can be set by the implementation.

TODO in open-forms:

  • Add onLanguageChange page reload to /src/openforms/forms/templates/forms/sdk_snippet.html

src/sdk.spec.js Outdated Show resolved Hide resolved
@robinmolen robinmolen force-pushed the issue/4600-changing-language-doesnt-translate-some-links branch from 998b84a to dd430f1 Compare October 8, 2024 13:42
@robinmolen robinmolen force-pushed the issue/4600-changing-language-doesnt-translate-some-links branch from dd430f1 to 10a1ea4 Compare October 8, 2024 13:54
@sergei-maertens sergei-maertens merged commit 8ba7da2 into main Oct 8, 2024
15 checks passed
@sergei-maertens sergei-maertens deleted the issue/4600-changing-language-doesnt-translate-some-links branch October 8, 2024 14:14
@sergei-maertens
Copy link
Member

Backports:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-backport Fix must be backported to stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changing the language doesn't properly translate some links
2 participants