Really strange behavior that makes Kirby save to wrong content file

panel
#22

As far as I understand it, the added field sets the panel language here: https://github.com/getkirby/panel/blob/master/app/src/panel.php#L272

Using a different name, by prefixing it, renders this useless. Doesn’t it?

0 Likes

#23

Yes, you are right, I overlooked that. But isn’t this supposed to get the language from the language select field not from this hidden field?

0 Likes

#24

Exactly! That’s why it works.

Normally the language query parameter is set by the language switcher in the upper right corner of the panel. But when you submit a form, that field is not included. The panel sends the data just hoping that the info in the session is correct. Therefore I suggested (see post #8) to include a hidden field with name language, mimicking the switcher, so that the panel language is reset to whatever language the POST “came from”.

IMHO the hidden field should stay there being posted together with the data, because conceptually it belongs there. The safest and easiest way to ensure consistency between data and metadata is to send it together. The session should really not be used to try and mirror the client application state. Just think about tabs: what happens if I try to have 2 tabs in different languages? It’s impossible to model this correctly in a session.
In fact this issue can be demoed simply with tabs:

  1. download the langkit and put it on a server
  2. access the panel
  3. go to a page in the panel
  4. duplicate the tab, let’s call them Tab A and B
  5. open Tab B and change the panel language with the switcher (this sets the session info to a new language)
  6. go back to tab A and just hit save (without refreshing first)

You just deleted the contents in the language of tab B.

And this use-case isn’t even far fetched, just think about someone translating a page: it’s not that uncommon to want the original content in another window aside. This is currently impossible, unless you remember “the correct order of refreshes”.

IMHO 2 the User panel view should be corrected to not use “language” as a key, exactly like the other blueprints where you can’t use “language” as a field name (because it is reserved for the panel).
In fact, this currently causes a minor “misbehavior” of the panel:

  1. in the langkit installation of before, set the language to english (just close the other tab)
  2. go to the user admin view
  3. create a random new user and set his language to “deutsch”
  4. save
  5. return to the dashboard and notice that your panel now is also set to Deutsch

Of course one could leave the user view like it is and rename the language switcher instead, to something more unique, like: “kirbypanel_language” or something…

0 Likes

#25

Ok, I deleted my post as it does not make sense without further changes.

This definitely needs are more robust overall solution.

0 Likes

#26

Anyway, I hope we will have a solution soon, the milestone is currently set to 2.5.8. The next RC is already out, so there will be no fix in Kirby 2.5.7 yet.

0 Likes