getkirby / kirby

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

Structure field performance #4554

Open mynameisfreedom opened 2 years ago

mynameisfreedom commented 2 years ago

Hi, structure field is great field, and very usable for many situations, but it is by far the slowest field. If there are several structure fileds in the panel page, it becomes very slow. It loads very slow, and it saves changes even slower.

It is easy to reproduce with two approaches:

It works slow in every Kirby 3+ version. If there is any option to improve performance of that field it will be super welcomed.

afbora commented 2 years ago

Could you share your blueprint file please?

mynameisfreedom commented 2 years ago

Hi, @afbora, can't do it today, but I will as soon as possible. Thank you!

mynameisfreedom commented 2 years ago

Hi, sorry for the delay, here is a blueprint for testing. It is a block blueprint, just add it as a new block in your blocks. It is a simplified slider block, where the structure field has options for one image, a blocks field for content, and a few options fields.


name: Slideshow
icon: layers

tabs:
  # content tab
  content:
    label: 
      en: Content
      de: Inhalt
    icon: edit
    fields:
      # slideshow
      slideshow:
        label: 
          en: Slideshow items
          de: Slideshow-Elemente
        type: structure
        columns: 
          slideImage: 
            width: 2/3
          slideContentPosition:
            width: 1/3
        max: 5
        help: 
          en: Maximum 5 items allowed.
          de: Maximal 5 Artikel erlaubt.
        fields:
          # slide image
          slideImage:
            label: 
              en: Slide image
              de: Slide Bild
            type: files
            query: site.images.add(page.images)
            layout: cards
            size: small
            multiple: false
            width: 1/2
            image:
              cover: true
          # kirbytext
          slideContent:
            label: 
              en: Slide content
              de: Slide Inhalt
            type: blocks
            width: 1/2
          # content position
          slideContentPosition:
            label: 
              en: Slide content position
              de: Position des Inhalts verschieben
            type: select
            default: " uk-position-bottom-left"
            options:
              " uk-position-top-left": Top left
              " uk-position-bottom-left": Bottom left
              " uk-position-top": Top
              " uk-position-left": Left
              center: Center
            width: 1/2
          slideContentPositionCenter:
            label: 
              en: Slide content position center
              de: Schieben Sie die Inhaltsposition in die Mitte
            type: select
            default: " uk-position-center"
            options:
              " uk-position-top-center": Top center
              " uk-position-center-left": Center left
              " uk-position-bottom-center": Bottom center
              " uk-position-center": Center
            width: 1/2
            when:
              slideContentPosition: center
          slideContentWidth:
            label: 
              en: Slide content width
              de: Breite des Folieninhalts
            type: select
            placeholder: Auto
            options:
              " uk-width-1-3@s": 1/3
              " uk-width-1-2@s": 1/2
              " uk-width-2-3@s": 2/3
            width: 1/2

HOW TO TEST:

NOTE I think that the blocks field inside structure field is making the biggest slowdown. A structure field in a block that have Kirby markdown instead of blocks field is a lot faster. It slows down too, but not that much.

afbora commented 2 years ago

I checked. Yes, we are experiencing the same problem in our own themes (especially in nested blocks).

There's a ticket/issue for this that we're tracking in the backlog. In fact, even PR (https://github.com/getkirby/kirby/pull/3623) work was done on this issue. It has not merged, but we are aware of the problem. I can't say for sure when it will be resolved. It requires many parts to be refactored.

mynameisfreedom commented 2 years ago

That's good news. The solution starts when we are all aware of the problem. Thank you!

andreasnymark commented 1 year ago

(Adding to this issue per @afbora request)

Better loading feedback Panel users are sometimes left in an unknown state, not aware the panel is currently working in the background. This happens when user adds a new item, saves an edit or paginates between items.

Expected behavior Visual feedback in relation to where the user is working. Disable fields and show a spinner? Dim fields and show a spinner on top? Spinner on button/pagination?