8000 fix(trade): fixed yield widget navigation issue by fairlighteth · Pull Request #5790 · cowprotocol/cowswap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(trade): fixed yield widget navigation issue #5790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

fairlighteth
Copy link
Contributor
@fairlighteth fairlighteth commented Jun 6, 2025

Summary

Fixes #5424

Fixed Yield widget navigation issue where clicking the Yield menu item would redirect users back to Swap page instead of
opening the Yield widget.

To Test

  1. Navigate to Yield widget

    • Click on "Yield" menu item in navigation
    • Verify it navigates to /yield route without redirecting back to Swap
    • Verify Yield tab remains active/highlighted in navigation
  2. Unlock screen functionality

    • Verify unlock screen displays with "Start boooosting your yield!" button
    • Click unlock button and verify yield widget interface loads
    • Verify navigation tab stays active throughout the process
  3. Other trade types still work

    • Verify Swap, Limit, and Advanced tabs still redirect to default tokens when accessed without URL parameters
    • Verify no regression in existing navigation behavior

Background

The issue was in useSetupTradeState.ts where the trade state logic was resetting routes with empty tokens (no input/output currency) back to the default Swap page. This reset logic was intended for Swap/Limit/Advanced routes that require tokens, but was incorrectly being applied to the Yield route which is designed to work without pre-selected tokens and has its own token selection interface.

The fix excludes Yield routes from the "tokens are empty" reset logic while preserving the existing behavior for other trade types.

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection of the active menu item for "yield" routes in the trade widget navigation.
    • Prevented unnecessary resetting of the trade state when navigating to a "yield" trade route, even if no tokens are selected.

Copy link
vercel bot commented Jun 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
cowfi ✅ Ready (Inspect) Visit Preview Jun 9, 2025 10:56pm
explorer-dev ✅ Ready (Inspect) Visit Preview Jun 9, 2025 10:56pm
swap-dev ✅ Ready (Inspect) Visit Preview Jun 9, 2025 10:56pm
3 Skipped Deployments
Name Status Preview Updated (UTC)
cosmos ⬜️ Ignored (Inspect) Visit Preview Jun 9, 2025 10:56pm
sdk-tools ⬜️ Ignored (Inspect) Visit Preview Jun 9, 2025 10:56pm
widget-configurator ⬜️ Ignored (Inspect) Visit Preview Jun 9, 2025 10:56pm

Copy link
Contributor
coderabbitai bot commented Jun 6, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The updates adjust the logic for activating the Yield menu link and for resetting trade state in the frontend. The active state logic for the Yield route now accounts for chain ID, and the trade state reset is prevented when navigating to a Yield route with empty tokens, ensuring the Yield widget can open as intended.

Changes

File(s) Summary
apps/cowswap-frontend/src/modules/trade/containers/TradeWidgetLinks/index.tsx Refined active menu item logic for the Yield route to include chain ID in the pathname check.
apps/cowswap-frontend/src/modules/trade/hooks/setupTradeState/useSetupTradeState.ts Added logic to prevent resetting trade state when on a Yield route with empty tokens.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant TradeWidgetLinks
    participant useSetupTradeState

    User->>TradeWidgetLinks: Navigate to Yield widget
    TradeWidgetLinks->>TradeWidgetLinks: Check if Yield route is active (with chain ID)
    Note right of TradeWidgetLinks: Active state set using stricter path check

    User->>useSetupTradeState: Open Yield widget with empty tokens
    useSetupTradeState->>useSetupTradeState: Check if tokens are empty & if route is Yield
    alt Route is Yield & tokens are empty
        useSetupTradeState-->>User: Do not reset trade state
    else
        useSetupTradeState-->>User: Reset trade state
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Fix Yield widget so it can be opened when feature-flag is on (#5424)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Suggested reviewers

  • alfetopito
  • shoom3301

Poem

The Yield route shines with logic anew,
No more resets when tokens are few.
The widget opens, the bug is gone—
With chain IDs checked, we hop along!
🐇✨

CodeRabbit brings the fix with glee,
Now Yield trades work as they should be!


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@fairlighteth
Copy link
Contributor Author

Ready to review, but putting in DRAFT to not have 3 PRs open at a time.

@fairlighteth fairlighteth removed the request for review from a team June 6, 2025 17:10
const INITIAL_CHAIN_ID_FROM_URL = getRawCurrentChainIdFromUrl()
const EMPTY_TOKEN_ID = '_'

// TODO: Break down this large function into smaller functions
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also addressed this.

Copy link
Contributor
@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

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

Hey @fairlighteth , great job!
There is only one issue:

  1. open yield tab

  2. connect to a wallet

  3. using network selector, switch to another network --> tokens will be prepopulated into the form, however, should not
    image

  4. go to the swap/limit/twap --> tokens will not be picked, tokens from the previous network will be displayed in the URL
    image

I'm approving this PR with this issue as it can be addressed when we start working on the Yield again in the future.

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.

Yield cannot be opened
2 participants
0