verbb / navigation

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

Max nodes per level can be easily bypassed using drag-and-drop #359

Closed MoritzLost closed 1 year ago

MoritzLost commented 1 year ago

Describe the bug

The Max Nodes per Level can be easily bypassed by dragging a nested item to a new position. For example, we have a limit of three nodes for level one. This prevents the editor from adding more nodes through the sidebar. However, a nested entry (level 2 or lower) can be moved to level 1 using drag-and-drop without problems. When a node is moved to a level where it's not allowed like this, all nodes on that level can't be saved because they encounter a validation error due to the nodes limitation.

Setting a node to a level where no more nodes are allowed using drag-and-drop should be prevented.

Steps to reproduce

  1. Set the max nodes per level to three.
  2. Create three nodes at level 1, and at least one node at level 2.
  3. Drag the node from level 2 to 1.
  4. Try to edit and save any of the nodes at level 1.

Craft CMS version

4.4.13

Plugin version

2.0.18

Multi-site?

No response

Additional context

No response

engram-design commented 1 year ago

Good call, and possibly going to need some help from Craft on this one.

MoritzLost commented 1 year ago

With the new events added in Craft 4.5 it should now be possible to address this issue, right? 🌞

engram-design commented 1 year ago

So, sort of. The only thing I'm not overly happy about is that when moving the element and it's invalid, you'll get an A server error occurred. error message, and not something more meaningful. There's not much we can do about that.

Added for the next release (for Craft 4.5+ only). To get this early, run composer require verbb/navigation:"dev-craft-4 as 2.0.21".

MoritzLost commented 1 year ago

@engram-design Thanks! Yeah I agree, showing a meaningful error message would be preferable.

engram-design commented 1 year ago

Updated in 2.0.22