Skip to content

fix(address-input): drop chain-prefix warning when recipient is cleared - #7720

Merged
kernelwhisperer merged 8 commits into
cowprotocol:developfrom
tenderdeve:fix/7687-recipient-prefix-warning-clear
Jul 9, 2026
Merged

kernelwhisperer merged 8 commits into
cowprotocol:developfrom
tenderdeve:fix/7687-recipient-prefix-warning-clear

Conversation

@tenderdeve

@tenderdeve tenderdeve commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #7687.

On the swap page with custom recipient enabled, pasting a chain-prefixed address that doesn't match the source chain (e.g. `plasma:0x…` on Base) shows a "wrong prefix" warning above the input. Clicking the Clear button on the recipient field emptied the input but left the warning hanging, because the warning was only reset inside `useOnAddressInput.handleInput` — and Clear bypasses that path (it just calls `onChange('')`).

Fix

Pass the current input `value` into `useOnAddressInput` and clear `chainPrefixWarning` whenever it becomes empty. Covers the Clear button, QR-scan reset, and any future external reset.

Files

  • `apps/cowswap-frontend/src/common/pure/AddressInputPanel/hooks/useOnAddressInput.ts`
  • `apps/cowswap-frontend/src/common/pure/AddressInputPanel/ReceiverPanelBody.container.tsx`

Testing steps

  1. Connect a wallet on Base.
  2. Enable the custom recipient option on the swap page.
  3. Paste `plasma:0x17a40f2F463d360FbF1769c3fFF9520c259F69F4` into the recipient field — the chain-prefix warning appears.
  4. Click the "Clear" button — the warning should disappear together with the address.

Summary by CodeRabbit

  • Bug Fixes
    • Address input prefix warnings now reliably clear when the address field is emptied or externally reset.
    • Address validation feedback stays synchronized with the current input, including Clear-button and reset flows.
  • Tests
    • Added coverage to verify the warning-clear behavior when the input value is externally updated to an empty string.

The chain-prefix warning (e.g. "plasma:" pasted into a Base recipient
field) was only reset inside \`useOnAddressInput.handleInput\`. The
\"Clear\" button invokes \`onChange('')\` directly and never triggers
\`handleInput\`, so the warning stayed visible above an empty field
until the user typed something or re-pasted.

Pass the current input \`value\` into \`useOnAddressInput\` and reset
\`chainPrefixWarning\` whenever it goes empty, covering the Clear button,
QR-scan reset, and any future external reset path.

Closes cowprotocol#7687
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@tenderdeve is attempting to deploy a commit to the cow-dev Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 80dcd3a8-5f10-405b-9221-99fec6b6be44

📥 Commits

Reviewing files that changed from the base of the PR and between 5d3e145 and 219e9fd.

📒 Files selected for processing (1)
  • apps/cowswap-frontend/src/common/pure/AddressInputPanel/hooks/useOnAddressInput.test.ts

Walkthrough

useOnAddressInput now accepts the current input value and clears chainPrefixWarning when that value becomes empty. ReceiverPanelBody.container passes the value through, and the hook test covers the external clear path.

Changes

Chain-prefix warning clear on empty recipient input

Layer / File(s) Summary
Hook signature, effect, and caller wiring
apps/cowswap-frontend/src/common/pure/AddressInputPanel/hooks/useOnAddressInput.ts, apps/cowswap-frontend/src/common/pure/AddressInputPanel/ReceiverPanelBody.container.tsx, apps/cowswap-frontend/src/common/pure/AddressInputPanel/hooks/useOnAddressInput.test.ts
useOnAddressInput adds an optional value?: string parameter and a useEffect that clears chainPrefixWarning when value is empty. ReceiverPanelBody.container passes the current input value, and the hook test verifies the warning is cleared after an external reset.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: elena-zh, fairlighteth, shoom3301

Poem

🐇 The bunny saw a prefix frown,
ثم poof—clear button calmed it down.
A tiny hook watched empty space,
And hid the warning from its place.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: removing the chain-prefix warning when the recipient is cleared.
Description check ✅ Passed It includes the issue reference, a clear fix summary, and testing steps; the template isn't exact but the required information is present.
Linked Issues check ✅ Passed The change clears the warning when the recipient value becomes empty, matching the acceptance criteria in #7687.
Out of Scope Changes check ✅ Passed Only the hook, its caller, and a regression test were changed, and all are directly related to the reported bug.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@elena-zh elena-zh added the trigger-preview Add to a fork PR to trigger CF-pages preview. See https://github.com/cowprotocol/cowswap/pull/7615 label Jun 23, 2026
@github-actions

github-actions Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Cloudflare Pages preview mirror

Preview branch URL: https://github.com/cowprotocol/cowswap/tree/cf-preview/pr-7720
Mirror PR: #7723
Cloudflare Pages preview links will be posted on the mirror PR by the Cloudflare Pages GitHub integration once builds complete.

Source fork branch: tenderdeve/cowswap:fix/7687-recipient-prefix-warning-clear
Approval target SHA: 5c1524f75718
Last mirrored SHA: d96ba28a32fe
Last comment update: @kernelwhisperer at 2026-07-09T14:18:48.691Z

  • Sync Cloudflare preview to approval target commit

@github-actions github-actions Bot removed the trigger-preview Add to a fork PR to trigger CF-pages preview. See https://github.com/cowprotocol/cowswap/pull/7615 label Jun 23, 2026
@vercel
vercel Bot temporarily deployed to Preview – storybook June 23, 2026 14:59 Inactive
@vercel
vercel Bot temporarily deployed to Preview – widget-configurator June 23, 2026 14:59 Inactive
@vercel
vercel Bot temporarily deployed to Preview – cowfi June 23, 2026 15:00 Inactive
@vercel
vercel Bot temporarily deployed to Preview – storybook June 23, 2026 15:50 Inactive
@vercel
vercel Bot temporarily deployed to Preview – widget-configurator June 23, 2026 15:50 Inactive
@vercel
vercel Bot temporarily deployed to Preview – cowfi June 23, 2026 15:51 Inactive

@elena-zh elena-zh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tnx!

@elena-zh
elena-zh requested a review from a team June 23, 2026 16:02
@elena-zh
elena-zh requested review from Danziger and removed request for a team June 24, 2026 09:02

@fairlighteth fairlighteth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ AI Review (Codex GPT-5, worked 5m): add a regression test for the cleared warning

Finding: [NON-BLOCKING] Add coverage for the external clear path

  • Location: apps/cowswap-frontend/src/common/pure/AddressInputPanel/hooks/useOnAddressInput.ts:46
  • The fix looks aligned with issue #7687, but the existing useOnAddressInput.test.ts still only covers input-driven resets and addressPrefix changes.
  • A focused regression test would catch this exact bug if the external value -> '' sync is changed later.

Suggested fix

  • Add a hook test that creates a wrong-prefix warning, rerenders the hook with value: '', and expects chainPrefixWarning to clear.
  • Alternatively, cover the same flow at AddressInputPanel level by clicking Clear after a wrong-prefixed recipient.
Review scope and related context

Checked against the current PR head and linked issue #7687. I found no blocker: the clear-button fix matches the reported AR/ER. Existing PR context has no inline review threads; CodeRabbit generated no actionable comments, and there is one human approval.

🤖 Prompt for AI agents
Verify this finding against current PR code. If still valid, add a minimal regression test for useOnAddressInput.

Context:
- Changed code: apps/cowswap-frontend/src/common/pure/AddressInputPanel/hooks/useOnAddressInput.ts
- Existing tests: apps/cowswap-frontend/src/common/pure/AddressInputPanel/hooks/useOnAddressInput.test.ts
- Expected coverage: after a wrong-prefix warning exists, rerendering with value='' clears chainPrefixWarning.

Generated using the pr-review skill from the CoW Protocol skills repo.

Add regression test for useOnAddressInput: after a wrong-prefix warning
exists, rerendering with an empty value clears chainPrefixWarning. Guards
the Clear-button path that syncs value to '' without going through handleInput.

Addresses @fairlighteth's review feedback.
@tenderdeve

Copy link
Copy Markdown
Contributor Author

@fairlighteth added the regression test in 219e9fd — after a wrong-prefix warning exists, rerendering useOnAddressInput with value: '' now asserts chainPrefixWarning clears, covering the external Clear-button path. Full suite (11 tests) green.

@elena-zh
elena-zh requested a review from fairlighteth July 7, 2026 09:05
@vercel

vercel Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
swap-dev Ready Ready Preview Jul 7, 2026 9:09am

Request Review

@vercel
vercel Bot temporarily deployed to Preview – swap-dev July 7, 2026 09:09 Inactive
@kernelwhisperer
kernelwhisperer enabled auto-merge (squash) July 7, 2026 13:36
@kernelwhisperer
kernelwhisperer merged commit af96bfa into cowprotocol:develop Jul 9, 2026
12 of 20 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong prefix message is not removed when clear out the recipient field

4 participants