Display of default range field value not working inside structure field

Hi,

When you set a default value for a range field that is inside a structure field, the value is set but not displayed in the tooltip.

              opacity:
                default: 0.2
                label: Opacity
                max: 1
                min: 0.1
                step: 0.1
                type: range
                when:
                  overlay: custom
                width: 1/2

This is what it looks like when loaded:

Once you click:

Which version do you use? This issue fixed on 3.2.5 and i can’t reproduce on 3.3.1.

You get the value properly displayed when loading the page, before you touch the input? On your screenshot you’ve clicked the input. Just to make sure…

No, i did’nt click to field on load:

@johan On a side note: It would help if you always copy the full field definition, not only parts of it. Then we can copy and paste it into our reference projects in the same way you have it in your blueprint.

Sorry. Here’s the full field:

          styleHero:
            default:
              - align: align-center
            label: Style
            max: 1
            translate: false
            type: structure
            fields:
              align:
                label: Align
                options:
                  align-center: Center
                type: select
              opacity:
                default: 0.2
                label: Opacity
                max: 1
                min: 0.1
                step: 0.1
                type: range

Still getting the empty tooltip.

Thanks, @johan.

I also see the number in the tooltip.

I can reproduce on 3.3.1 after page created in structure field.
But i’m not sure this is a bug.
Because you didn’t define it in the default values.

Works like that:

styleHero:
  default:
  - opacity: 0.2

Oh, right, I only tested in existing page, if I create a new page, I get the same result.

Yes that solves it with the tooltip. But I only allow one row. When adding the opacity to the default, it creates two rows when creating a new page. How do you add default values to the same row?

styleHero:
  default:
    - align: align-center
    - opacity: 0.2

        default:
          -
            align: align-center
            opacity: 0.2
2 Likes

Thanks so much for your help @texnixe and @ahmetbora!!

1 Like

As a side note, after some thoughts. It should also work having the default value inside the corresponding field, in this case as in my first code, inside the opacity field. And not to the structure field. Currently I’m adding the opacity as a default attached to the structure field, but it’s just a hack to have the tooltip display the value when first viewed.

In my case the opacity field is just shown when another field is selected. Hence, the value isn’t needed every time. Having the default value attached to the structure field, there will always be a default value in the content file.

opacity: “0.2”

Even though it’s not used.

If the default is attached to the opacity field instead, when that field is not used and the row is saved the value in the content file will be blank:

opacity: “”

Which to me makes more sense.