From 7931060d43849d468635c1e18f06bc5a22917c07 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Thu, 26 Feb 2026 17:49:09 +0100 Subject: [PATCH] Fix number inputs not syncing to dict until blur dict_number() only wrote to seq[key] on blur, so changing a value (e.g. via spinner arrows) and immediately clicking Save could race the save ahead of the blur on the server. Now also syncs on update:model-value so the dict is always current. Co-Authored-By: Claude Opus 4.6 --- tab_batch_ng.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tab_batch_ng.py b/tab_batch_ng.py index 27e5ae9..ab3d3cc 100644 --- a/tab_batch_ng.py +++ b/tab_batch_ng.py @@ -89,7 +89,7 @@ def dict_input(element_fn, label, seq, key, **kwargs): def dict_number(label, seq, key, default=0, **kwargs): - """Number input bound to seq[key] via blur.""" + """Number input bound to seq[key] via blur and model-value update.""" val = seq.get(key, default) try: # Try float first to handle "1.5" strings, then check if it's a clean int @@ -99,15 +99,16 @@ def dict_number(label, seq, key, default=0, **kwargs): val = default el = ui.number(label, value=val, **kwargs) - def _on_blur(e, k=key, d=default): - v = e.sender.value + def _sync(k=key, d=default): + v = el.value if v is None: v = d elif isinstance(v, float) and v == int(v): v = int(v) seq[k] = v - el.on('blur', _on_blur) + el.on('blur', lambda _: _sync()) + el.on('update:model-value', lambda _: _sync()) return el