Skip to content

refactor(escrow): decompose EscrowSigningModal into hook/lib + presentational component #440

Description

@Josue19-08

🔧 Title:

refactor(escrow): decompose EscrowSigningModal into hook/lib + presentational component

📘 Description

src/components/escrow/EscrowSigningModal.tsx (682 lines) mixes several concerns in one file: the step/operation copy tables (STEP_INFO, OPERATION_FALLBACK_INFO, getStepInfo), error-code-to-copy mapping (errorCopy, stateTitle), focus-trap/Escape-key/tab-cycling dialog accessibility logic, and substantial JSX for its 5 render states (building, awaiting signature, submitting, confirmed, error).

Grown from 296 to 682 lines in the recent step-context UX work (Frontend PR #435), which was the right UX fix but didn't address the pre-existing single-file mixing of copy data, a11y logic, and rendering.

✅ Acceptance Criteria

  • Step/operation copy tables and mapping functions (STEP_INFO, OPERATION_FALLBACK_INFO, getStepInfo, errorCopy, stateTitle) extracted into a dedicated file (e.g. src/lib/escrow-signing-copy.ts) — pure data/functions, no JSX
  • The focus-trap/Escape-key/Tab-cycling modal a11y logic extracted into a reusable hook (e.g. useFocusTrapModal) — check src/components/ui/ first in case an equivalent already exists to consolidate onto, per the "no duplicate types/logic" standard
  • EscrowSigningModal.tsx reduced to primarily JSX composed from the extracted hook/lib
  • npx tsc --noEmit, npx eslint, npx vitest run, and npm run build all stay clean
  • No behavior/visual change — this is a structural refactor only, existing EscrowSigningModal.test.tsx must keep passing unmodified (or with only import-path updates)

🔧 Context AI

📋 Additional Notes

Part of the Frontend Architecture & Standards Cleanup milestone, not a paid Tranche deliverable. Check other modal components (RefundModal, OpenDisputeModal, etc.) for an existing shared focus-trap hook before writing a new one — several of them implement the same open/Escape/backdrop-click pattern independently, which may itself be worth consolidating as a follow-up.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    choreMaintenance / setupfrontendFrontend related

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions