verbb / navigation

A Craft CMS plugin to create navigation menus for your site.
Other
90 stars 23 forks source link

Querying the empty navigation field return wrong value. #324

Closed aodihis closed 2 years ago

aodihis commented 2 years ago

Describe the bug

Currently we have a navigation field in our entry to chose which navigation that will show on that page, it is working if the value is non empty but if we decide to not chose any navigation it return random value.

Steps to reproduce

  1. Create some navigation types
  2. Create a section with navigation field.
  3. Create entry and leave the navigation field empty
  4. Do query to that entry, some random value will appear.

Also would it possible instead of return the list of node only, it also returns the navigation type information, like this :

field { 
   handle
  title
  node {
     id
     url
     title
 }
}

Craft CMS version

4.3.1

Plugin version

2.0.10

Multi-site?

No

Additional context

No response

engram-design commented 2 years ago

Fixed for the next release. To get the fix early, change your verbb/navigation requirement in composer.json to:

"require": {
  "verbb/navigation": "dev-craft-4 as 2.0.10",
  "...": "..."
}

Then run composer update. It's however also reliant on this fix for Craft itself.

As for your suggestion, that would require a breaking change, which will mess up how people query at the moment. We'll have to shelve it for the time being. I would suggest:

navigationField {
  id
  handle
  name

  nodes {
     id
     url
     title
  }
}
aodihis commented 2 years ago

Thank you for the reply and fix, really appreciate it.

engram-design commented 2 years ago

Fixed in 2.0.11