getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.32k stars 168 forks source link

Table layout pages section: interactive previews are not updating content #6582

Open twiro opened 3 months ago

twiro commented 3 months ago

Description:

If a toggle field is included as a column in a list of pages in table layout the preview of the field behaves buggy/irritating:

A) Example A

Blueprint:

example_a:
  label: Table
  type: pages
  layout: table
  columns:
    toggle:
      label: Toggle Field Table Preview

Screenshot of the resulting table:

Bildschirmfoto 2024-07-29 um 14 26 24

Expected behavior / Problem:

With that preview given (especially as the UI feels fully functional) I'd expect the toggle value to get saved whenever I use a toggle in the table – only, it doesn't!

More Context:

Looks like this preview was originally implementend for the structure field and works there. (Haven't tested that actually)

B) Example B

In the forum I ran across the idea to use type: text for the preview of a toggle field in table layout, but that doesn't result in a satisfying experience either:

Blueprint:

example_b:
  label: Table
  type: pages
  layout: table
  columns:
    toggle:
      label: Toggle Field Table Preview
      type: text

Screenshot of the resulting table:

Bildschirmfoto 2024-07-29 um 14 27 01

Expected behavior / Problem:

If changing the preview of a toggle field to text in a table column is actually possible, I'd expect to see the toggle text values I defined in my blueprint (Ja, Nein) or at least the default text values for the given language (an, aus) – but all i get is true and false.

C) Example C

Thinking about the text values of the toggle field preview a little more neither true and false nor the default text values of the given language (an and aus) do feel really convincing here – if the values can be customized in the blueprint, the only really satisfying solution for the field preview would be to have it customazible there too. If not automatically, then at least by redefining the values in the columns-settings of the table:

Blueprint:

example_c:
  label: Table
  type: pages
  layout: table
  columns:
    toggle:
      label: Toggle Field Table Preview
      type: toggle
      text:
        - "Nein"
        - "Ja"

Screenshot of the resulting table:

Bildschirmfoto 2024-07-29 um 14 26 24

Expected behavior / Problem:

Apart from the missing saving-functionality described in example A, I'd expect to see Ja and Nein used instead of an and aus.

Setup / System

distantnative commented 3 months ago

@twiro For me, this really boils down to the issue in (A). As you spotted yourself, the preview was initially created for the structure field and then they are getting re-used now for the tables layout of sections. However, we need to fix them that they either really update the page content or that in sections they are display only without any interaction.

(B) works as intended and expected, displaying the content field value as text. We aren't looking up the field type in addition when the column type is defined, it gets treated as that type.

(C) I don't see much value here currently in re-implemnting the logic twice. You can define the texts for the different states on the actual field.