statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
4.11k stars 538 forks source link

Conditional field in nav_group not working? #11077

Closed stephenmeehanuk closed 1 week ago

stephenmeehanuk commented 2 weeks ago

Bug description

I've added a menu_columns button group to my nav_group blueprint.

I've set it to be conditional. I only want the button group to show if the depth = 1

The conditional hides it everywhere, regardless of depth?

This is the blueprint

       handle: menu_columns
            field:
              options:
                -
                  key: one
                  value: '1'
                -
                  key: two
                  value: '2'
                -
                  key: three
                  value: '3'
                -
                  key: four
                  value: '4'
              default: one
              type: button_group
              display: 'Menu Columns'
              always_save: true
              if:
                depth: 'equals 1'

How to reproduce

40 Second video shows the issue and setup. https://github.com/user-attachments/assets/44566d23-a608-4997-8658-3ea019fac254

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 11.29.0
PHP Version: 8.3.8
Composer Version: 2.6.5
Environment: local
Debug Mode: OFF
URL: website.test
Maintenance Mode: OFF
Timezone: America/New_York
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: redis
Database: sqlite
Logs: stack / single
Mail: log
Queue: redis
Session: file

Livewire
Livewire: v3.5.12

Statamic
Addons: 5
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.34.0 PRO

Statamic Addons
jonassiewertsen/statamic-jobs: 1.5.0
jonassiewertsen/statamic-live-search: 2.1.1
jonassiewertsen/statamic-livewire: 3.8.1
statamic/collaboration: 1.0.0
visuellverstehen/statamic-anchor-navigation: 1.0.0

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

jasonvarga commented 2 weeks ago

Field conditions require referencing other fields. depth isn't a field.

However depth has now been made available in #11080. Upgrade to 5.37.

stephenmeehanuk commented 2 weeks ago

Thanks, I've updated but I'm still seeing the same issue. menu_columns doesn't show at all when I add the conditional

if:
                depth: 'equals 1'

https://github.com/user-attachments/assets/7a685cfe-46d7-46ca-b6b4-f8bd279d81f0

Full nav blueprint below.

tabs:
  main:
    display: Main
    sections:
      -
        fields:
          -
            handle: menu_columns
            field:
              options:
                -
                  key: 1
                  value: null
                -
                  key: 2
                  value: null
                -
                  key: 3
                  value: null
                -
                  key: 4
                  value: null
              default: '4'
              type: button_group
              display: 'Menu Columns'
              always_save: true
              if:
                depth: 'equals 1'
          -
            handle: hide_link
            field:
              type: toggle
              display: Hide
Environment
Application Name: Statamic
Laravel Version: 11.30.0
PHP Version: 8.3.8
Composer Version: 2.6.5
Environment: local
Debug Mode: OFF
URL: website.test
Maintenance Mode: OFF
Timezone: America/New_York
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: redis
Database: sqlite
Logs: stack / single
Mail: log
Queue: redis
Session: file

Livewire
Livewire: v3.5.12

Statamic
Addons: 5
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.37.0 PRO

Statamic Addons
jonassiewertsen/statamic-jobs: 1.5.0
jonassiewertsen/statamic-live-search: 2.1.1
jonassiewertsen/statamic-livewire: 3.8.1
statamic/collaboration: 1.0.0
visuellverstehen/statamic-anchor-navigation: 1.0.0
stephenmeehanuk commented 2 weeks ago

Also noticed a selected button in the button group doesn't stay selected if it uses numbers instead of text

https://github.com/user-attachments/assets/ef5812b3-a7db-4856-aa92-c204f5134c5e

The selected value is saved, it just doesn't show it within the button group.

              options:
                -
                  key: 1
                  value: null
                -
                  key: 2
                  value: null
                -
                  key: 3
                  value: null
                -
                  key: 4
                  value: null
jasonvarga commented 2 weeks ago

Oh in a nav. Sorry I misunderstood. Thought you were editing the entry.