getkirby / kirby

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

Command + S in structure editor in a block saves structure item’s title as block’s title #6087

Closed frankrausch closed 1 week ago

frankrausch commented 7 months ago

Description

I have a blocks template that contains a structure.

When I edit an item from the structure in Kirby 4’s panel and press the keyboard shortcut ⌘S, the structure item’s title is wrongly saved as the block’s title (= overwriting the title field of its parent). This doesn’t happen if I use the save icon in the toolbar.

Expected behavior

Screenshots

To reproduce

  1. Create a template with a blocks field that contains a structure where both the block and the structure have a field called title.
  2. Edit a structure item and press ⌘S or Ctrl + S while editing.
  3. Observe that the structure item’s title overwrites the block’s title.

Here is a shortened version of the block template:

name: field.blocks.listblock1.name
fields:
  title: # <-- block title
    label: Headline
    type: text
  anchorTitle:
    label: Anchor Title
    help: used as ID to scroll to this block
    type: text
  text:
    label: Text
    type: textarea
    size: small
  items:
    label: Items
    type: structure
    fields:
      title: # <-- structure item title
        type: text
        required: true
      text1:
        type: textarea
      text2:
        type: textarea

Your setup

Kirby Version
4.0.2

Console output

Your system (please complete the following information)

Additional context

Thanks!

distantnative commented 7 months ago

I cannot reproduce your problem so far, for me the title always stays field.blocks.listblock1.name

https://github.com/getkirby/kirby/assets/3788865/59f72472-6183-4952-830d-4601384ed959

frankrausch commented 5 months ago

Sorry for the long wait! Finally found some time to do a deep-dive into this. I could not reproduce it in a clean new project at first either.

But when I copied my content file from the actual site, I could reproduce it, even after I removed all of my own content.

Here is a screencast and a minimal reproduction. The zip file contains the content and site folders, derived from a current plainkit. The template is in about.yml and the blocks are in the block-factory plugin.

https://github.com/getkirby/kirby/assets/6783714/0b5f422e-1767-42be-b680-c7de0d996c23

kirby-issue-6087.zip

distantnative commented 1 month ago

@frankrausch Finally have a hunch. Could you test if the problem disappears if you remove the date fields? I think it could be the same as https://github.com/getkirby/kirby/issues/6390

frankrausch commented 1 week ago

@distantnative Yes! Removing the date field seems to fix this bug.

I commented out the date fields in my blocks blueprints and now it behaves correctly (doesn’t mess up the parent when editing a child and pressing Command + S).

distantnative commented 1 week ago

Will be fixed in v4.4. then :)

frankrausch commented 1 week ago

Thanks!