Sitelet https://github.com/ChainSafe/canton-snap/pull/72
Skip to content

fix(dapp): pre-select the clicked token on Transfer - #72

Merged
sadiq1971 merged 3 commits into
mainfrom
fix/transfer-preselect-token
Jun 4, 2026
Merged

sadiq1971 merged 3 commits into
mainfrom
fix/transfer-preselect-token

Conversation

@sadiq1971

Copy link
Copy Markdown
Member

Summary

Clicking Send → on a balances row opened the Transfer tab but always defaulted to the first token in the list, not the one the user clicked. Now the clicked token is pre-selected.

Changes

  • DashboardBalancesPage: new onSendToken(tokenAddress) prop; the row's Send → passes token.address instead of a bare tab switch.
  • App: holds a transferToken address; handleSendToken sets it then opens Transfer, while plain sidebar nav (handleTabChange) clears it so Transfer still defaults to the first token when reached normally. Cleared on disconnect.
  • TransferPage: new optional preselectTokenAddress; on load selects the matching token (case-insensitive), falling back to list[0].

Test

  • npm run lint ✅ and npm run build ✅ (packages/dapp).
  • Manual: Balances → Send → on a non-first token opens Transfer with that token selected; sidebar → Transfer still defaults to the first token.

Closes #66

A balances row's "Send →" opened Transfer but always defaulted to the
first token in the list rather than the one clicked. Thread the chosen
token address from the balances row through App into TransferPage, which
now pre-selects the matching token (falling back to the first token when
opened via plain sidebar navigation).

Closes #66

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request implements a feature to pre-select a token on the Transfer page when navigating from the Balances page via the "Send →" button. Feedback on the changes highlights a performance issue in TransferPage.tsx, where including preselectTokenAddress in the main data-fetching useEffect dependency array causes redundant network requests and UI flashes. The reviewer suggests decoupling the pre-selection logic into a separate, lightweight useEffect and reverting the dependency array to only depend on address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/dapp/src/pages/TransferPage.tsx
Comment thread packages/dapp/src/pages/TransferPage.tsx Outdated
Address review feedback: reading preselectTokenAddress inside the main
token-fetch effect's dependency array refetched the whole token list and
balances whenever it changed. Capture it in a ref (it's fixed for the
page's lifetime) and read it inside the async load, so deps stay [address]
and a pre-selection no longer triggers a refetch or loading flash.

Also stop tracking .claude/ (accidental scheduled_tasks.lock) and ignore it.
@salindne
salindne self-requested a review June 4, 2026 11:43

@salindne salindne 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.

fix seems correct, the perf concern from gemini was addressed in a cleaner way than gemini proposed

@sadiq1971
sadiq1971 merged commit b76a02a into main Jun 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transfer modal always defaults to first token, not the one clicked

2 participants