Electric v3 bubbling tree value challenge: • given a nested tree component with nodes • each node has entries & child nodes which can be expanded • how to search for entries at each node level, return a count to parent so that the parent can selectively expand tree branches where leaf nodes have matching entries? Essentially a feedback loop from leaf to root, so that root can decide which nodes to expand to reveal matching nodes.
your goal is a folding treeview UX, like macos finder?
essentially, yes - to expand all subtrees that have matching child "files" when searching for a needle I could do a global search from the caller and pass down a list of all folder IDs that contain matching files, but then I'm repeating the search query. would be nice if the leaf nodes could pass up this information to the caller and it decides how to expand the tree I could probably use a set atom for this so each child conducting a search with results adds its ID (& parent IDs?) to the set, so the root can expand those if those IDs are present in the set during sarching.
maybe I could use the DOM's bubbling events to trigger a sort of 'click' event from a child when it has matches and the parent has an event listener for that?
e.g. in parent:
(dom/On "expand" (fn [_e] (reset! !expand-children? true)) nil)
and in child,
(.dispatchEvent dom/node (js/Event. "expand"))
?Hey, it works!
awesome
Checkbox: why does the dom/text label render before the input instead of after?
...even though dom/text point effect is after the dom/input
ahhh, it must be because checked?' is only referenced after the dom/text, i.e. lazy let. let me see what happens if I put checked?' before the dom/text.
fixed with this. quite unintuitive that you can bind a dom element to let-symbol, but it does not render twice if you render it.
i think its a bug
i expect your original program to put the dom/input inside the dom/label, above the dom/text
is it not expected because the let-binding to dom/input was first used after the dom/text, so it races?
I moved the virtual scroll fetch query out of e/Offload, and now I see this error in browser controle after some activity and lots of elements on screen. No logs on server.
before that, it shows this:
[Violation] 'setTimeout' handler took <N>ms
electric_dom3_events.cljc:18 [Violation] 'click' handler took 2199ms
electric_dom3_events.cljc:18 [Violation] 'click' handler took 1601ms
electric_scroll0.cljc:14 [Violation] 'scroll' handler took 610ms
electric_scroll0.cljc:14 [Violation] 'scroll' handler took 201msHowever, this does not seem to deadlock reactor for everyone else – just that one client. So not the same symptom.