fix: mobile keyboard popping up when app returns from background#14289
Merged
Conversation
Instruments three key contest interactions following the existing
'Remix Contest:' event prefix and {remixContestId, trackId} property
shape used by the host/pick-winners events:
- REMIX_CONTEST_VIEW: contest page/screen first resolves trackId+eventId
- REMIX_CONTEST_ENTER: user taps Enter Contest / Upload Remix
- REMIX_CONTEST_VIEW_SUBMISSIONS: user opens the submissions tab
Mobile submissions-tab firing uses useFocusedTab from
react-native-collapsible-tab-view because the contest tabs mount
eagerly (lazy: false) — a plain mount effect would fire even for
users who only view the Details tab.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…round The search input was being re-focused on every navigation focus event via `useFocusEffect` — including when the app returned from background while explore was the active tab. If the user had tapped the search icon before backgrounding (without dismissing the keyboard first), `params.autoFocus` remained true and the keyboard popped up again on resume. Replace `useFocusEffect` with `useEffect` so the focus only fires when the param transitions to true (initial mount or a subsequent search-icon tap), not on every screen focus. Consume the param by immediately setting it back to false so the next tap can re-trigger. Drops the redundant `autoFocus` prop on the TextInput (the effect handles initial mount too) and the `keyboardDidHide` listener (no longer needed once focus stops firing on every screen refocus). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The mobile keyboard was popping up unexpectedly when the app first loads (specifically: when returning from background while the explore tab was the active tab).
Root cause
SearchExploreHeader.tsxwas usinguseFocusEffectto call.focus()on the search input whenever the screen gained focus ANDparams.autoFocus === true. WithfreezeOnBlur: trueon the tab stacks, the explore screen stays mounted across tab switches. When the user tapped the search icon, navigated to explore (params.autoFocus: true), and then backgrounded the app without dismissing the keyboard,params.autoFocusremainedtrue. On app resume, React Navigation fires a fresh focus event →useFocusEffectre-runs → keyboard pops up.Fix
useFocusEffectwith a plainuseEffectkeyed onparams?.autoFocus— fires only when the param transitions, not on every screen focus.setParams({ autoFocus: false })after focusing, so the same useEffect can re-trigger on a subsequent search-icon tap.autoFocusprop on the TextInput (the effect handles initial mount too) and thekeyboardDidHidelistener (no longer needed now that focus stops firing on screen refocus).Test plan
🤖 Generated with Claude Code