Altinn / app-frontend-react

Altinn application React frontend
BSD 3-Clause "New" or "Revised" License
14 stars 24 forks source link

language does not change in DataProcessor and FormDataValidator when using language selector #2037

Closed CelineTrammi closed 3 weeks ago

CelineTrammi commented 4 weeks ago

Description of the bug

This might be a feature request also, dependent on the motivations behind adding string language to DataProcessor in https://github.com/Altinn/app-lib-dotnet/pull/405.

As this issue (https://github.com/Altinn/app-lib-dotnet/issues/16) mentions, the backend should be informed of language changes. For DataProcessor and FormDataValidator, the methods now include a string for language in v8.

However, when a user selects a different language then the one they initiated the app with, the language field does not change in DataProcessor and FormDataValidator.

Is there a way to synchronize these? Or are we using lanuageSelector wrong?

Steps To Reproduce

  1. Create app with language selector using "uiSettings": { "showLanguageSelector": true } in layout-sets.json
  2. In DataProcessor.ProcessDataWrite(), set a breakpoint or display the languageparam and compare before and after changing the language

Additional Information

No response

ivarne commented 3 weeks ago

Transfering this to frontend, as they need to implement an empty patch to inform backend that language has changed. This has been discussed previously but probably not implemented.

bjosttveit commented 3 weeks ago

It seems like the language gets stuck to whatever was selected first. If I have en selected when opening the page, it will send patch requests with language=en. If I then switch using the language selector to nb it will still send patch requests with language=en. I can see that we generate the url once, and then store it for future use. This was probably done since the url differs between regular and stateless apps, but this also includes the language parameter.