) => p.then(refetch).catch((e) => setErr(String(e?.message ?? e)));
const isUB = ant.type !== 'steppir';
@@ -125,16 +127,24 @@ function MotorAntennaWidget({ ant, refetch, t }: { ant: AntStatus; refetch: () =
// +/- starts from the real values rather than blind.
useEffect(() => { if (isUB && ant.connected) readLengths(); }, [isUB, ant.connected, readLengths]);
- // Nudge one element by ±2 mm from its current known length.
- const nudge = async (i: number, delta: number) => {
- const cur = lengths[i] ?? 0;
- const next = Math.max(0, cur + delta);
+ // Send an absolute length to one element and remember it as the new baseline.
+ const setLen = async (i: number, mm: number) => {
+ const next = Math.max(0, Math.round(mm));
setBusyEl(i); setErr('');
setLengths((ls) => { const c = [...ls]; c[i] = next; return c; }); // optimistic
try { await MotorSetElement(i, next); refetch(); }
catch (e: any) { setErr(String(e?.message ?? e)); }
finally { setBusyEl(null); }
};
+ // Nudge one element by ±2 mm from its current known length.
+ const nudge = (i: number, delta: number) => setLen(i, (lengths[i] ?? 0) + delta);
+ // Commit a typed exact length (click on the mm value). Lets the operator fix
+ // the baseline when the auto-read is off, so +/- then work reliably.
+ const commitEdit = (i: number) => {
+ const v = parseInt(editVal, 10);
+ setEditingEl(null);
+ if (!isNaN(v) && v >= 0 && v !== lengths[i]) setLen(i, v);
+ };
const dirs: [number, string][] = [[0, 'N'], [1, '180°'], [2, t('station.bi')]];
return (
@@ -191,9 +201,19 @@ function MotorAntennaWidget({ ant, refetch, t }: { ant: AntStatus; refetch: () =
className="flex items-center justify-center size-7 rounded-md border border-border hover:bg-muted disabled:opacity-40 shrink-0">
-
- {busyEl === i ? : `${mm} mm`}
-
+ {editingEl === i ? (
+ setEditVal(e.target.value)}
+ onBlur={() => commitEdit(i)}
+ onKeyDown={(e) => { if (e.key === 'Enter') commitEdit(i); if (e.key === 'Escape') setEditingEl(null); }}
+ className="text-sm font-mono font-bold flex-1 min-w-0 text-center tabular-nums bg-transparent border border-primary rounded px-1" />
+ ) : (
+ { setEditingEl(i); setEditVal(String(mm)); }}>
+ {busyEl === i ? : `${mm} mm`}
+
+ )}