Skip to content

fix(bridge): support cursor-aware custom slippage input#27920

Merged
bfullam merged 3 commits into
mainfrom
swaps-slippage-input-cursor
Mar 27, 2026
Merged

fix(bridge): support cursor-aware custom slippage input#27920
bfullam merged 3 commits into
mainfrom
swaps-slippage-input-cursor

Conversation

@bfullam

@bfullam bfullam commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Description

This PR makes the custom slippage modal cursor-aware. It adds a dedicated slippage cursor hook that reuses the shared raw cursor editing utilities, wires controlled selection / onSelectionChange through InputStepper, preserves the existing slippage-specific max and decimal validation rules, resets cursor state when the stepper buttons change the value, and sanitizes trailing decimals such as 2. before saving the selected slippage.

Changelog

CHANGELOG entry: Fixed custom slippage input so keypad edits respect cursor placement and trailing decimals are sanitized before saving.

Related issues

Fixes:

Manual testing steps

Feature: custom slippage cursor-aware editing

  Scenario: user inserts a digit at a chosen cursor position
    Given the user opens Bridge and opens the custom slippage modal
    And the custom slippage value is "12.5"

    When the user places the caret between "1" and "2"
    And the user taps "5" on the keypad
    Then the displayed custom slippage value updates to "152.5"

  Scenario: user resets the cursor by using the stepper buttons
    Given the user opens Bridge and opens the custom slippage modal
    And the user places the caret in the middle of the custom slippage value

    When the user taps the "+" stepper button
    And the user taps "5" on the keypad
    Then the next keypad edit follows the new stepper-updated value instead of the old caret position

  Scenario: user confirms a value with a trailing decimal
    Given the user opens Bridge and opens the custom slippage modal
    And the custom slippage value is "2."

    When the user taps "Confirm"
    Then the saved slippage value is "2"

Screenshots/Recordings

Before

N/A

After

N/A

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Touches user input/editing logic in the Bridge slippage flow (cursor mapping + keypad handling), which can introduce subtle edge-case regressions, but scope is localized and covered by new tests.

Overview
Makes the Bridge CustomSlippageModal cursor-aware by introducing useCustomSlippageCursor, which tracks and maps selection between formatted and raw values and applies keypad edits at the current caret position (while preserving max/decimal validation and over-max flagging).

Extends InputStepper to accept controlled selection/onSelectionChange, wires these through the slippage modal, resets cursor state when +/- stepper buttons adjust the value, and sanitizes trailing decimals (e.g., 2. -> 2) before dispatching setSlippage. Tests are updated/added to cover cursor insertion/backspace behavior, trailing-decimal sanitization, and the new selection plumbing.

Written by Cursor Bugbot for commit b963576. This will update automatically on new commits. Configure here.

@bfullam bfullam requested a review from a team as a code owner March 25, 2026 15:20
@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-swaps-and-bridge Swaps and Bridge team label Mar 25, 2026
@github-actions github-actions Bot added size-L risk-low Low testing needed · Low bug introduction risk labels Mar 25, 2026
@bfullam bfullam changed the title Add cursor-aware editing to custom slippage input fix(bridge): support cursor-aware custom slippage input Mar 25, 2026
@bfullam bfullam force-pushed the swaps-slippage-input-cursor branch from c0a13c5 to 250e552 Compare March 25, 2026 15:47
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 25, 2026

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 25, 2026
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeTrade, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 92%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are entirely scoped to the Bridge SlippageModal UI components:

  1. InputStepper - Added optional selection and onSelectionChange props to support cursor-aware text input
  2. useCustomSlippageCursor - New hook managing cursor position state for the slippage keypad input
  3. CustomSlippageModal - Refactored to use the new cursor hook, with trailing decimal sanitization on confirm

These changes improve the UX of the custom slippage input in the Bridge flow (cross-chain bridging), allowing users to edit at specific cursor positions rather than always appending. The changes are low-risk UI refinements with no impact on core logic, controllers, navigation, or shared components.

SmokeTrade is selected because the Bridge cross-chain feature is directly affected (slippage modal is part of the bridge flow).
SmokeConfirmations is selected per the tag description: "when selecting SmokeTrade for swap/bridge, also select SmokeConfirmations."

No other tags are warranted as the changes don't touch accounts, identity, network management, snaps, ramps, or any other feature areas.

Performance Test Selection:
The changes are minor UI input handling improvements (cursor position management for a text input in the slippage modal). There is no impact on rendering performance, data loading, state management at scale, or any of the performance-sensitive flows covered by the available performance test tags.

View GitHub Actions results

@github-actions

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
17 value mismatches detected (expected — fixture represents an existing user).
View details

@sonarqubecloud

Copy link
Copy Markdown

@bfullam bfullam added this pull request to the merge queue Mar 27, 2026
Merged via the queue into main with commit 5b49b16 Mar 27, 2026
96 checks passed
@bfullam bfullam deleted the swaps-slippage-input-cursor branch March 27, 2026 14:20
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2026
@metamaskbot metamaskbot added the release-7.73.0 Issue or pull request that will be included in release 7.73.0 label Mar 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.73.0 Issue or pull request that will be included in release 7.73.0 risk-low Low testing needed · Low bug introduction risk size-L team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants