summaryrefslogtreecommitdiff
path: root/web/src/lib/ui/CharacterRow.svelte
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/lib/ui/CharacterRow.svelte')
-rw-r--r--web/src/lib/ui/CharacterRow.svelte20
1 files changed, 16 insertions, 4 deletions
diff --git a/web/src/lib/ui/CharacterRow.svelte b/web/src/lib/ui/CharacterRow.svelte
index 043c225..b4f9b48 100644
--- a/web/src/lib/ui/CharacterRow.svelte
+++ b/web/src/lib/ui/CharacterRow.svelte
@@ -73,6 +73,16 @@
let initInput = $state<HTMLInputElement | null>(null);
let initDraft = $state('');
+ // Seed the editable field from (re)synced state so a reload or reconnect
+ // doesn't blank an entry we already made. Skip while the field is focused
+ // (clicking it clears it for re-entry) so we never clobber a live edit.
+ $effect(() => {
+ const v = cs.initiative;
+ if (v == null || v <= 0) return;
+ if (initInput && document.activeElement === initInput) return;
+ if (String(v) !== initDraft) initDraft = String(v);
+ });
+
// `??` for a value masked by the server; the revealed number otherwise.
const initDisplay = $derived(
cs.initiative === null ? '??' : cs.initiative > 0 ? String(cs.initiative) : ''
@@ -223,11 +233,13 @@
}}
></div>
</div>
-</div>
-{#if unclaimed}
- <button class="chip chip--claim" onclick={() => session.claim(item.id)}>Claim</button>
-{/if}
+ <!-- The claim chip anchors to the row (position:relative) so it sits in
+ the row's corner; kept inside `.row` so it moves with it. -->
+ {#if unclaimed}
+ <button class="chip chip--claim" onclick={() => session.claim(item.id)}>Claim</button>
+ {/if}
+</div>
<style>
/* The summon standees sit above the row, like the reference. */