PR: #718: fix(add-matter): reset participant label on type change [Story-2795] by @ayush-pramaan
View PR →
Story-2795 · Add matter

A matter-type change cannot carry the old represented party

Changing the matter type keeps the answer to “Is there an opposing side?” but clears “Who we represent.” Counsel must choose a valid participant label from the newly selected type before creating the matter.

The protected transition

Matter type
Arbitration
Is there an opposing side?
Adversarial
Who we represent
Claimant
Respondent
→
Matter type
Writ Petition
Is there an opposing side?
Adversarial
Who we represent
Petitioner
Respondent

Result: the old Claimant selection is gone, Petitioner is available but unselected, and Create requires a fresh Q2 choice.

What changed — and what did not

Concern Behavior
Form state A real matter-type identity change clears the adversarial participant-label object, removing both its id and name.
Q1 Adversarial stays adversarial. Advisory stays advisory and Q2 remains hidden.
Q2 data The existing generated query remains the only fetch. Its query key already includes matterTypeId, so changing the type supplies the new options without another fetch path.
New type has no labels The existing empty state appears. No stale old-type label can be submitted through it.
Same type selected again The selection is retained because the type identity did not change.

Automated proof

tests/unit/representing-side-field.test.tsx exercises the complete regression path with two query-cache entries: choose type A, choose Adversarial, pick Claimant, switch to type B, then assert the stored label is cleared and Petitioner appears unselected.

The existing tests and stories continue to cover Q2 loading, empty, retryable error, no-type, required-selection, and Advisory-hidden states.

Files changed

2 file(s), +105 / -1 lines

Path Role + -
src/components/add-matter/use-add-matter-drawer-form.tsComponent+20-0
tests/unit/representing-side-field.test.tsxTest+85-1