xilem icon indicating copy to clipboard operation
xilem copied to clipboard

xilem_masonry: Add filter ("All", "Active", "Completed") to todomvc example

Open Philipp-M opened this issue 9 months ago • 13 comments

This adds the filters of TodoMVC via checkboxes currently (as we currently don't have better widgets for that...).

It also revealed (at least) 2 bugs, one being fixed by #264 and another I (or someone else) needs to investigate (difficult to describe just add a few todos, check them, and click all the filters, it should be easy to reproduce).

Philipp-M avatar May 05 '24 16:05 Philipp-M

Nicely done, but as you point out, this PR makes these other bugs very visible. I'd rather not merge it until they are fixed, since this is our showcase. ^^

PoignardAzur avatar May 05 '24 18:05 PoignardAzur

Sure, I also think this should only be merged, when it doesn't produce obvious bugs at this point :). But I think it's probably good for debugging these bugs.

Philipp-M avatar May 05 '24 18:05 Philipp-M

(Now this weird issue can be debugged, since #264 is merged)

Philipp-M avatar May 05 '24 18:05 Philipp-M

I ran in (I think) the same issue that you are describing, put some reproduction steps here: https://xi.zulipchat.com/#narrow/stream/354396-xilem/topic/TodoMVC.20example/near/437314215

bram209 avatar May 06 '24 18:05 bram209

Since #278 is merged, I've tested this again, it works now as expected

Philipp-M avatar May 06 '24 20:05 Philipp-M

I tested this. I think this filter should be placed before the list: image This makes it so that it doesn't move around when you're using it.

I do find that it's in need of polish. You're using multi-select checkboxes as radio buttons. If we're going with multi-select, you technically don't want an All option, and instead check both options. I don't know what level of polish we're going for this week.

jaredoconnell avatar May 06 '24 21:05 jaredoconnell

I think this filter should be placed before the list: This makes it so that it doesn't move around when you're using it.

For what it's worth, it also moves around in the examples on todomvc.com.

xStrom avatar May 06 '24 22:05 xStrom

Yes checkboxes are not ideal indeed, these should be exchanged with the right widgets, when they're implemented.

I'm not sure how much we're striving towards the original TodoMVC.

Philipp-M avatar May 07 '24 09:05 Philipp-M

I've been looking through our PR backlog, and I'd be interested in merging this, if everything works correctly after a rebase.

I'm fine having checkboxes masquerade as combo buttons for now, as long as we track it in an issue. We can add a big ugly "TODO - replace with combo buttons" comment to the example.

PoignardAzur avatar Aug 16 '24 11:08 PoignardAzur

I've rebased it (+ added comment), and well it revealed yet another new bug^^ (this example seems to be a quite good test as well)

To reproduce: Press "Active" and then "Buy milk"

Philipp-M avatar Aug 16 '24 12:08 Philipp-M

Hmm, so the behaviour we see is that the checkbox "thinks" it is clicked, but without sending an action.

That's very strange

DJMcNab avatar Aug 16 '24 13:08 DJMcNab

I rebased this again, to check whether that issue resolved itself - not the case. I've found another issue (that is actually the issue for the other one as well): It's possible to toggle the checkboxes, whereas I'd expect, that these should behave more like radio-buttons, since they should be driven by xilem.

So the issue is related to two-way dataflow and non-keyed widgets/viewsequences. I.e. masonry modifies the checkbox value while it shouldn't do it (at least in this case). This opens the broader question about two-way/unidirectional dataflow/state again.

I think this is an example, that two-way dataflow can be a pitfall for declarative frameworks on top of masonry. I think it would be great to find a general clean solution for this issue (something like opt-in control of the state in masonry, as in this case).

I've pushed a "fix"/workaround, which should make this work as expected.

Philipp-M avatar Sep 23 '24 18:09 Philipp-M

This seems like a very "brute force" solution to the two-way dataflow problem, buuuuut nobody has a better idea, so we may as well ship it.

PoignardAzur avatar Sep 24 '24 09:09 PoignardAzur