prevwong / craft.js

🚀 A React Framework for building extensible drag and drop page editors
https://craft.js.org
MIT License
7.56k stars 733 forks source link

isDeletable is inadequate - or just plain wrong. #644

Open eschiebel opened 4 months ago

eschiebel commented 4 months ago

Describe the bug The docs imply that craft.rules.canMoveOut can be used as a test for being deletable, but it is only called on dragging. The isDeletable function will return true as long as it's not the root node or a top-level node, which is probably inconsistent with the canMoveOut rule.

To Reproduce Steps to reproduce the behavior:

  1. go to the landing page demo at https://craft.js.org/
  2. try to drag the sole button out of the Custom3 "I must have 1 button" section, you cannot
  3. now click the trashcan in the toolbar - the button is deleted

Expected behavior If you can't drag a component out, you should not be able to delete it.

Screenshots

Additional context Since drag and drop is problematic for keyboard only users, this is an accessibility issue as well.

Your environment

Software Version(s)
craft.js 0.2.6
React
TypeScript
Browser
npm/Yarn
Operating System