Skip to content

Fix safe access for array paths#368

Open
queenvictoria wants to merge 3 commits into
hunvreus:mainfrom
queenvictoria:copilot/fix-safe-access-for-array-paths
Open

Fix safe access for array paths#368
queenvictoria wants to merge 3 commits into
hunvreus:mainfrom
queenvictoria:copilot/fix-safe-access-for-array-paths

Conversation

@queenvictoria

Copy link
Copy Markdown
Contributor

Updated the safeAccess function to handle the case where a path segment resolves to an array. When traversing a dot-separated path (e.g. date.start) and the current accumulated value is an array (because date is an object field with list: true), it now implicitly uses the first element ([0]) before continuing with the next path segment.

@hunvreus

Copy link
Copy Markdown
Owner

Why would you do that? It already supports date[0].start.

@queenvictoria

queenvictoria commented Mar 28, 2026

Copy link
Copy Markdown
Contributor Author

Hey Ronan. Yeah I thought it should work but that's not my experience. I'm running 2.0.2. I've attached before and after screenshots and yaml. Is it because...no actually I've no idea.

Without this fix:

image
    view:
      fields: [title, showing[0].start]
      sort: [title, showing[0].start]
      default:
        search: ''
        sort: showing[0].start
        order: desc
    fields:
      - name: showing
        label: Showing
        type: object
        list: true
        fields:
          - name: start
            label: Start date
            component: date
          - name: end
            label: End date
            component: date
            required: false

With this fix:

image
    view:
      fields: [title, showing.start]
      sort: [title, showing.start]
      default:
        search: ''
        sort: showing.start
        order: desc

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants