Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigations can't access group data when it has a condition #10055

Closed
JonKaric opened this issue May 13, 2024 · 8 comments · Fixed by #10086
Closed

Navigations can't access group data when it has a condition #10055

JonKaric opened this issue May 13, 2024 · 8 comments · Fixed by #10086

Comments

@JonKaric
Copy link
Contributor

JonKaric commented May 13, 2024

Bug description

When you create a group and give it a condition of show when, you can no longer access the data if a child precedes it.

  • Introduced in V5
  • Not tested in other blueprints, only navigation ones

Copy the data below and try re-ordering them inside your navigation to see what I mean.

How to reproduce

inside antlers:

<div class="p-10 bg-blue-100">
    {{ nav:test }}
        {{ title }}
        <div class="p-10 m-10 bg-red-200">
            {{ children }}
            {{ title }}
                <span class="block text-xs rounded-full bg-slate-200">
                    Type: {{ type }}
                </span>
                <span class="block text-xs rounded-full bg-slate-200">
                    Columns: {{ test_group.columns }}
                </span>
                <span class="block text-xs rounded-full bg-slate-200">
                    Rows: {{ test_group.rows }}
                </span>
                <span class="block text-xs rounded-full bg-slate-200">
                    Text: {{ test_text }}
                </span>
            {{ /children }}
        </div>
    {{ /nav:test }}
</div>

content/navigation/test.yaml

title: test

content/trees/navigation/default/test.yaml

tree:
  -
    id: 2a92b97a-81c7-45c3-8ac5-51abcfbe2c62
    title: Home
    children:
      -
        id: 93d23cc8-7634-43bc-95b9-b3b934e64468
        title: 'Group 1'
        data:
          type: row
          test_text: null
      -
        id: 9b22f158-4c69-4e03-9be1-181e3fa2fe7d
        title: 'Group 2'
        data:
          type: column
          test_group:
            columns: '2'
            rows: Two
          test_text: 'Group 2'

resources/blueprints/navigation/test.yaml

tabs:
  main:
    display: Main
    sections:
      -
        fields:
          -
            handle: type
            field:
              options:
                column: Column
                row: Row
              type: select
              display: Type
          -
            handle: test_group
            field:
              type: group
              display: 'Test Group'
              if:
                type: 'equals column'
              fields:
                -
                  handle: columns
                  field:
                    options:
                      1: '1'
                      2: '2'
                    type: select
                    display: Columns
                -
                  handle: rows
                  field:
                    type: text
                    display: Rows
          -
            handle: test_text
            field:
              type: text
              display: 'Test Text'
              if:
                type: 'equals column'

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 10.48.10
PHP Version: 8.2.11
Composer Version: 2.5.5
Environment: local
Debug Mode: ENABLED
Maintenance Mode: OFF

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

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Livewire
Livewire: v3.4.12

Statamic
Addons: 3
Sites: 2 (en, fr)
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.1.0 PRO

Statamic Addons
jonassiewertsen/statamic-livewire: 3.3.1
statamic-rad-pack/shopify: 3.3.0

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

@robdekort
Copy link
Contributor

robdekort commented May 14, 2024

Not sure if I understand your issue and if it's similar. But I don't seem to get any navigation blueprint data returned in Antlers for root items. It does seem to work for children (in my case).

tree:
  -
    id: c818add2-f657-474b-ae28-fa4cec914bc2
    title: Follow
    data:
      contents: social_media
{{ nav:footer max_depth="2" select="contents|title|url|collection_source|buttons" }}
   {{ contents | dump }}

This dumps nothing. Only the Title and URL are available. When I dump the whole nav I don't see the data:
Screenshot 2024-05-14 at 08 55 58

@JonKaric
Copy link
Contributor Author

@robdekort Do you have any conditions anywhere? That is what seems to be messing mine up, but only for groups.

@robdekort
Copy link
Contributor

What do you mean with groups? Even without conditions the data doesn't seem available on root items. Only on children (in my case).

@JonKaric
Copy link
Contributor Author

Group fieldtypes (and possibly other fields that produce the same data structure, but I didn't test them)

@robdekort
Copy link
Contributor

Gotcha!

@robdekort
Copy link
Contributor

Mine might be a separate issue. We'll see :-)

@duncanmcclean
Copy link
Member

Mine might be a separate issue. We'll see :-)

It seems like both issues are related 😄

Reverting the changes made in #9636 seem to fix both issues.

@robdekort
Copy link
Contributor

Ah good. Jason suggested I create a separate one so it doesn’t get lost. I’ll do that tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants