Fixes batch 1: modal focus, campaign system, combat difficulty, origin desc

- Modal: focus into the dialog ONCE on open (not on every parent re-render), and
  prefer the first field over the X button — fixes focus jumping to the close
  button on each keystroke in the handout composer (and every other composer).
- Campaign edit: hide the System selector entirely (it's fixed after creation).
- Combat difficulty: rate against the PCs actually in the encounter (falls back to
  the roster) so adding a player updates the reading.
- Character builder: ancestry/background description is now a scrollable panel
  instead of clamped to 3 lines (no longer cut off on small screens).

223 unit + key e2e green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-08 21:48:31 +02:00
parent 99c7657f96
commit 426824fd78
4 changed files with 37 additions and 22 deletions
+12 -13
View File
@@ -258,19 +258,18 @@ function CampaignFormModal({ campaign, onClose }: { campaign?: Campaign; onClose
placeholder="Curse of Strahd"
/>
</Field>
<Field label="System">
<Select
value={system}
disabled={!!campaign}
onChange={(e) => setSystem(e.target.value as typeof system)}
>
{SYSTEM_OPTIONS.map((o) => (
<option key={o.id} value={o.id}>
{o.label}
</option>
))}
</Select>
</Field>
{/* System is fixed once a campaign exists (content + characters depend on it). */}
{!campaign && (
<Field label="System">
<Select value={system} onChange={(e) => setSystem(e.target.value as typeof system)}>
{SYSTEM_OPTIONS.map((o) => (
<option key={o.id} value={o.id}>
{o.label}
</option>
))}
</Select>
</Field>
)}
<Field label="Description">
<Textarea
value={description}
@@ -378,7 +378,7 @@ function OriginPicker({ title, options, value, onPick }: { title: string; option
))}
{options.length === 0 && <p className="text-xs text-muted">Loading</p>}
</div>
{sel?.desc && <p className="mt-1 line-clamp-3 text-xs text-muted">{sel.desc}</p>}
{sel?.desc && <p className="mt-1 max-h-32 overflow-y-auto whitespace-pre-wrap rounded-md border border-line bg-surface-2 p-2 text-xs text-muted">{sel.desc}</p>}
</div>
);
}
+4 -1
View File
@@ -71,7 +71,10 @@ export function EncounterTracker({ encounter, campaign }: { encounter: Encounter
// Difficulty budget from monster combatants vs the campaign's PCs. Once combat
// has started, rate against the levels captured at that time (snapshot) so the
// reading — and the assistant's history — reflects the party as it was.
const currentLevels = characters.filter((c) => c.kind === 'pc').map((c) => c.level);
// Rate against the PCs actually IN the fight (so adding a player updates the
// difficulty); fall back to the campaign roster before any PC is added.
const encounterPcLevels = encounter.combatants.filter((c) => c.kind === 'pc' && c.level !== undefined).map((c) => c.level as number);
const currentLevels = encounterPcLevels.length > 0 ? encounterPcLevels : characters.filter((c) => c.kind === 'pc').map((c) => c.level);
const partyLevels = encounter.partyLevelsSnapshot?.length ? encounter.partyLevelsSnapshot : currentLevels;
const monsters = encounter.combatants
.filter((c) => c.kind === 'monster')