Skip to content

fix(explore): stop the search keyboard flashing dark and smooth the search transition - #34575

Merged
vinnyhoward merged 3 commits into
mainfrom
fix-tmcu-1261-search-keyboard-and-transition
Aug 11, 2026
Merged

vinnyhoward merged 3 commits into
mainfrom
fix-tmcu-1261-search-keyboard-and-transition

Conversation

@vinnyhoward

@vinnyhoward vinnyhoward commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

Opening Explore search raised the keyboard while the screen was still animating in. On iOS the keyboard paints its translucent background from whatever sits behind it, so it rendered dark grey for roughly half a second and then snapped to its normal colour. The same mount also spun up the entire results subtree during the animation, which is what made the transition feel glitchy.

Both now wait for the push to finish.

What

  • New useScreenTransitionComplete hook — resolves on the native-stack transitionEnd event, with a 450 ms timer fallback so it always resolves (initial route, animation disabled, tests). Follows the existing transitionEnd pattern in CardWelcome and usePredictBuyActions.
  • ExploreSearchScreen gates two things on it — the keyboard, and the PerpsSectionProvider + results subtree whose mount blocks the JS thread mid-slide.
  • ExploreSearchBar takes an autoFocus prop (defaults to true, so Watchlist is unchanged). RN's autoFocus only applies on mount, so flipping it on later triggers an imperative focus.
  • keyboardAppearance now follows the theme — it was never passed, so the keyboard stayed light in dark mode regardless of app theme.

Why

The screen is a plain native-stack push (animation: 'ios_from_right', MainNavigator.js#L1425-L1429) and the input was hardcoded to autoFocus. Nothing coordinated the keyboard with the animation.

Symptom Cause Fix
Keyboard flashes dark grey for ~0.5s Keyboard raised mid-push; iOS samples the unsettled content behind it Focus after transitionEnd
Transition looks glitchy Perps stream + 5 search feeds + FlashLists mount during the animation Mount the results subtree after transitionEnd
Keyboard stays light in dark mode keyboardAppearance never set Derive it from the design-system theme

Trade-off: the keyboard now appears ~350 ms later, once the push completes. That is the fix, and it matches native iOS behaviour, but it is a deliberate responsiveness trade-off worth a reviewer's eye.

Changelog

CHANGELOG entry: Fixed the Explore search keyboard flashing dark grey and the search screen transition stuttering when opening search from Home or Explore

Related issues

Fixes: TMCU-1261

Manual testing steps

Feature: Explore search opens smoothly

  Scenario: user opens search from Explore
    Given the user is on the Explore tab
    When the user taps the search bar
    Then the screen slides in without stuttering
    And the keyboard rises after the slide completes
    And the keyboard never renders dark grey before settling

  Scenario: user opens search from Home
    Given the user is on the Home tab
    When the user taps the search icon in the header
    Then the search input is focused and the keyboard is shown
    And the user can type immediately without tapping the input

  Scenario: user opens search in dark mode
    Given the app theme is set to dark
    When the user opens Explore search
    Then the keyboard renders in its dark appearance

  Scenario: user opens search from a deeplink
    Given a deeplink with a search query, e.g. ?q=ethereum
    When the deeplink is opened
    Then the query is prefilled and results load for it

Screenshots/Recordings

after_keyboard.mov

Before

Keyboard is dark grey on first load (~0.5s), then settles

before_keyboard.mov

After

after_keyboard.mov

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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.
Test coverage
Suite Result
useScreenTransitionComplete.test.ts (new) 5 passed — transition event, closing event ignored, timer fallback, listener + timer cleanup
ExploreSearchBar.test.tsx 15 passed (3 new — autoFocus off, autoFocus flipped on after mount, themed keyboardAppearance)
ExploreSearchScreen.view.test.tsx 8 passed on iOS and Android (1 new — keyboard and results held back until settled)
TrendingView + Watchlist unit suites 50 suites / 466 tests passed
Related view tests (Wallet, TrendingView, Watchlist) 8 suites / 51 tests passed

lint, prettier, and lint:tsc are clean for the changed files. The lint:tsc errors that remain in the repo are pre-existing, in Perps and Engine.

Known follow-up: Watchlist search has the same bug

WatchlistFullScreenView uses the same ExploreSearchBar behind the same slideFromRightNativeOptions push, so its keyboard flashes the same way. It is untouched here (default autoFocus: true preserves today's behaviour) because it is outside TMCU-1261's scope. Applying the fix there is a two-line change: pass autoFocus={useScreenTransitionComplete()}.


Note

Low Risk
Localized UX/performance timing on Explore search with a tested navigation hook; keyboard appears slightly later by design.

Overview
Fixes Explore search opening during the native-stack push by coordinating keyboard focus and heavy UI with the enter animation.

Adds useScreenTransitionComplete, which flips to true on non-closing transitionEnd or after a 450ms focused-screen fallback (re-armed on focus). ExploreSearchScreen uses it to pass autoFocus={isTransitionComplete} and to defer mounting PerpsSectionProvider / search results until the slide finishes.

ExploreSearchBar gains an optional autoFocus prop (default true) with imperative focus() when it turns on after mount, plus keyboardAppearance derived from the design-system theme. Tests cover the hook, bar behavior, and the gated screen mount.

Reviewed by Cursor Bugbot for commit 1218560. Bugbot is set up for automated code reviews on this repo. Configure here.

The Explore search screen is a native-stack push and its input used
autoFocus, so the keyboard was raised while the push was still animating.
On iOS the keyboard paints its translucent background from whatever sits
behind it, so it rendered dark grey for ~0.5s before settling. Mounting
the results subtree (perps stream + five search feeds) during the same
frame also blocked the JS thread and made the transition look glitchy.

Add useScreenTransitionComplete, which resolves on the native-stack
transitionEnd event with a timer fallback, and gate both the keyboard and
the results subtree on it. Also set keyboardAppearance from the theme, so
the keyboard stops rendering light in dark mode.
@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.

@metamask-ci metamask-ci Bot added the team-mobile-ux Mobile UX team label Aug 11, 2026
@metamask-ci

metamask-ci Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Pre-merge author checklist has unchecked items (e.g. "I've tested on Android"). Every box must be consciously checked — see docs/readme/ready-for-review.md.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@vinnyhoward
vinnyhoward marked this pull request as ready for review August 11, 2026 14:17
@github-actions github-actions Bot added the risk:medium AI analysis: medium risk label Aug 11, 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 2 potential issues.

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.

Reviewed by Cursor Bugbot for commit c6c2913. Configure here.

The fallback timer fired unconditionally, so dismissing search before its
opening transitionEnd arrived (that event is ignored while closing) still
unblocked the screen mid-pop — mounting the perps stream and the results
subtree against the exit animation, only to tear them down.

Gate the fallback on navigation.isFocused() and re-arm it on focus, so a
screen that regains focus is not left permanently blocked.
@vinnyhoward
vinnyhoward enabled auto-merge August 11, 2026 16:38
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeSwap, SmokeStake, SmokeWalletPlatform, SmokeMoney, SmokePerps, SmokeMultiChainAPI, SmokePredictions, SmokeSeedlessOnboarding, SmokeBrowser, SmokeSnaps, SmokeMMConnect
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: high
  • AI Confidence: 100%
click to see 🤖 AI reasoning details

E2E Test Selection:
Hard rule (global-infrastructure-change): Global infrastructure changed: app/components/hooks/useScreenTransitionComplete.test.ts, app/components/hooks/useScreenTransitionComplete.ts. Running all tests.

Performance Test Selection:
The changes are UI/UX timing improvements that actually defer expensive work (PerpsSectionProvider + ExploreSearchContent subtree) until after screen transition. This is a performance improvement, not a regression. No performance test specs are changed, and the affected area (Trending search screen) is not covered by any of the available performance test tags (@PerformanceAccountList, @PerformanceOnboarding, @PerformanceLogin, @PerformanceSwaps, @PerformanceLaunch, @PerformanceAssetLoading, @PerformancePredict, @PerformancePreps).

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@vinnyhoward
vinnyhoward added this pull request to the merge queue Aug 11, 2026
Merged via the queue into main with commit 6cfd779 Aug 11, 2026
256 of 265 checks passed
@vinnyhoward
vinnyhoward deleted the fix-tmcu-1261-search-keyboard-and-transition branch August 11, 2026 22:08
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 11, 2026
@metamask-ci metamask-ci Bot added the release-8.8.0 Issue or pull request that will be included in release 8.8.0 label Aug 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-8.8.0 Issue or pull request that will be included in release 8.8.0 risk:medium AI analysis: medium risk size-M team-mobile-ux Mobile UX team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants