slint icon indicating copy to clipboard operation
slint copied to clipboard

Component catalogue in Design Mode includes component under preview, resulting in compilation errors on drop

Open tronical opened this issue 2 months ago • 2 comments

To reproduce:

  1. Open https://slintpad.com/
  2. Click "Design Mode" in the preview toolbar
  3. Observe "Demo" as entry in the component catalogue under "User Defined"
  4. Dragging "Demo" into the preview results in compilation failure.

Expected Result:

It should not be possible to drag "Demo" into the demo UI under preview. Either by it not being listed there, or being visually disabled for drag and drop.

tronical avatar Apr 24 '24 08:04 tronical

I'm not sure whether the component catalog should depends on the component under preview or not. But yes, we shouldn't allow dropping it.

We need to do some graph analysis of each component to know whether they contain the component under review or not or if it is allowed to import that file from the current file without causing recursion.

Considering this is not a simple task, I think we can live with this bug for the MVP though.

Edit: Although if it is in the same file, it should be easy to disallow dropping on component declared before the component we want to drop.

ogoffart avatar Apr 24 '24 08:04 ogoffart

Considering this is not a simple task, I think we can live with this bug for the MVP though.

I agree. I mean, I think for the MVP it would still be very beneficial to cover at least the most obvious cases that user will run into, such as the scenario you described with the declaration order. Just wanted to make sure we're tracking this issue.

I ran into this by accident as I ended up dragging the wrong thing while trying to see if I can use this already for a demo. It took just a few seconds, and once in this state it's very hard to get back (clicking into the text editor and pressing the undo shortcut being hard).

tronical avatar Apr 24 '24 08:04 tronical