hyperfiddle

braai engineer 2025-09-29T07:36:38.221799Z

How to do (dom/On "click" ...) on js/document in an Electric way so I can run e/fn on events? i.e. I want to do (.addEventListener js/document "click" (fn [e] (CallElectricFnHere)) but event handler is JS fn.

xificurC 2025-09-29T07:55:08.327719Z

Grab a token. When to (spend!) the token is use-case specific but generally πŸ‘‡

braai engineer 2025-09-29T07:57:11.845429Z

ah, I didn't realize dom/On could take an element as arg πŸ™‚ thx

braai engineer 2025-09-29T12:47:44.574289Z

I'm trying out the Virtual Scroll from the https://gitlab.com/hyperfiddle/electric-fiddle/-/blob/main/src/electric_tutorial/explorer.cljc: when I use the TableScroll component and pass a record-count of 1000, all 1000 elements render in DOM and it continuously keeps adding more rows instead of just the records that would fit on screen. Update: Fixed by adding max-height or height around TableScroll container div. Scroll-window could use some protection itself against unbounded container height. Scroll-window intially returns an offset of 0 with limit that starts at 1000 and it keeps adding more limit until it halts around ~8000 rows. explorer-css has the CSS from explorer example. I assume the loop is happening because rendering grows the page height, which increases .- scrollTop, which causes limit to grow and more elements to be added => neverending render. I'm surprised it renders beyond the record-count, though. If I cap limit via (IndexRing (min limit record-count) offset), it stops at record-count, but it still renders more elements than are visible. Am I missing a max-height somewhere?

Dustin Getz (Hyperfiddle) 2025-09-29T13:05:30.374809Z

to succeed here, start by replicating perfectly the actual example, css and all, and then incrementally modify to your use case

braai engineer 2025-09-29T13:05:54.595689Z

fixed with height or max-height πŸ™‚

Dustin Getz (Hyperfiddle) 2025-09-29T13:06:12.427499Z

if your css isn't perfect, you're going to be back with more issues

πŸ‘ 1
braai engineer 2025-09-29T13:52:53.972449Z

I got it working πŸ™‚ How can I make it play nice with a dom/thead & dom/tbody in a table? I imagine it's acout the placement of this :height setup:

(dom/div (dom/props {:style {:height (str (clamp-left ; row count can exceed record count
                                                  (* row-height (- record-count limit)) 0) "px")}}))

Dustin Getz (Hyperfiddle) 2025-09-29T13:56:10.832079Z

your question is ambiguous

Dustin Getz (Hyperfiddle) 2025-09-29T13:57:27.450589Z

studying the css here might help: https://electric.hyperfiddle.net/dustingetz.datomic-browser!DatomicBrowser/

Geoffrey Gaillard 2025-09-29T21:45:11.230799Z

As Dustin said, we'd need to know more about what you're trying to achieve. But here is a rule of thumb: β€’ One parent <table> with display:grid β€’ <thead> as a subgrid β€’ virtualscroll <tbody> as a subgrid too. This way head and body columns are consistent, and only the body is scrollable. display:content may help. Fixed height rows are good enough. Dynamic row height is certainly doable, but very hard.

braai engineer 2025-09-29T15:34:14.376609Z

Virtual Scroll: to persist the scroll offset between route navigations, what would I need to modify to pass in an initial scroll offset, scroll-state? Edit: Ah, I see there is a ((fn [_] (set! (.-scrollTop dom/node) 0)) record-count) in Scroll-window, so I could store the previous scroll value and override that instead of 0, but scroll may fail if element not tall enough.

braai engineer 2025-09-30T10:32:59.229379Z

In Virtual Scroll-window, shouldn't this:

((fn [_] (set! (.-scrollTop dom/node) 0)) record-count)
be:
((fn [_] (set! (.-scrollTop node) 0)) record-count)
?

xificurC 2025-09-29T18:53:08.742219Z

You'd need to persist search and sort state as well. Even then db changes could make the offset obsolete

braai engineer 2025-09-29T18:32:19.174959Z

I’m good at Electric v3 now and it’s so freaking cool. Will do a demo of my double-entry accounting ledger soon that I’m busy porting to Electric v3 from v2. The performance with virtual scroll is insane.

πŸ’ͺ 8
Dustin Getz (Hyperfiddle) 2025-09-29T20:10:32.278399Z

i want to see your accounting UI for sure

Dustin Getz (Hyperfiddle) 2025-09-29T20:12:34.946879Z

tell us how the v2->v3 port goes as well, a lot of people have asked about that

henrik 2025-09-29T22:37:51.884489Z

With Electric v3, you might even be able to do triple entry.

πŸ˜† 5