getkirby / kirby

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

[Panel] - Bug with date field when included in a structure field #6282

Open vauvarin opened 7 months ago

vauvarin commented 7 months ago

Description

I found a bug with the date field when it’s included in a structure field. If I choose a date in the calendar, the right date is displayed in the date field but when I click on the “tick” icon to close the sliding sidebar of the structure field then the date value is changed.

Looks like it only happens when the display format is set.

Expected behavior
We keep the same date value after clicking on the "tick" icon to close the sliding sidebar of the structure field.

Screenshots
I did two screencasts to illustrate: https://github.com/getkirby/kirby/assets/664089/beb95c5c-1ef8-4f97-a4c5-c820c9a1f806 https://github.com/getkirby/kirby/assets/664089/55157b3c-58c4-4de3-9c6b-1adf8cbb7086

To reproduce

f_primary_approval:
            label: Primary approval
            type: structure
            fields:
              f_s_title:
                label: Title
                type: text
              f_s_files:
                label: Egnyte files
                type: structure
                fields:
                  f_s_s_last_update_date:
                    label: Last update
                    type: date
                    display: MM/DD/YYYY
                    help: Click on the calendar icon

Your setup

Kirby Version
4.1.0

PHP Version
8.3.3

Your system (please complete the following information)

distantnative commented 6 months ago

Also getting weird dates when removing one nesting level with just

f_s_files:
  label: Egnyte files
  type: structure
  fields:
    f_s_s_last_update_date:
      label: Last update
      type: date
      display: MM/DD/YYYY
      help: Click on the calendar icon
Palutzii commented 3 months ago

Hi! I encountered the same issue. Have you found out what caused it? Any workarounds?

For me, the problem isn't in a structured field. I've noticed that using the display format DD/MM/YY triggers the bug. When I remove that format, the issue disappears.

HYR commented 3 months ago

I'm having a similar issue with a date field in structure field. The site is on Kirby 4.3.0 and when saved, the date value increase by 1 day. Similar to @vauvarin but the format we're using is YYYY-MM-DD. So possibly whatever is last in the "display format" is incremented causing some odd results?

HYR commented 3 months ago

Removing the the "display format" didn't help. It started working as expected once I removed the default: now prop. Hopefully that helps track down the issue.