Skip to content

fix(#72): improve autoFocus handling on AddSubscriptionScreen#489

Open
senmalong wants to merge 2 commits into
Smartdevs17:mainfrom
senmalong:fix/72-autofocus-keyboard-handling
Open

fix(#72): improve autoFocus handling on AddSubscriptionScreen#489
senmalong wants to merge 2 commits into
Smartdevs17:mainfrom
senmalong:fix/72-autofocus-keyboard-handling

Conversation

@senmalong
Copy link
Copy Markdown
Contributor

Summary

Closes #72

The autoFocus prop on the subscription name input caused the keyboard to open immediately on mount, blocking UI elements before the screen finished rendering — especially noticeable during the navigation transition on Android.

Changes

Commit 1 — Replace autoFocus with delayed focus via useRef

  • Added nameInputRef (useRef<TextInput>) to the name field
  • Removed the autoFocus prop from the name TextInput
  • Focus is now triggered programmatically after a 300 ms delay in a useEffect, giving the navigation transition time to complete on both platforms
  • Imported useRef from React

Commit 2 — Improve KeyboardAvoidingView and keyboard visibility tracking

  • Switched KeyboardAvoidingView behavior to 'padding' on iOS and undefined on Android (Android's scroll container handles this natively)
  • Added Keyboard listeners (keyboardWillShow/keyboardDidShow and their hide counterparts) to track isKeyboardVisible state
  • Applied extra bottom padding to the ScrollView content when the keyboard is open, keeping all form fields reachable
  • Imported Keyboard from react-native

Acceptance Criteria

  • UI is fully visible when the screen opens (keyboard does not immediately block elements)
  • Keyboard still opens automatically after the screen renders — user can still focus the field
  • KeyboardAvoidingView behaves correctly on iOS (padding) and Android (native scroll)
  • Form fields remain accessible when keyboard is open (extra scroll padding)
  • Works on both iOS and Android

Testing

Tested manually on:

  • iOS Simulator (iPhone 15, iOS 17)
  • Android Emulator (Pixel 7, API 34)

senmalong added 2 commits June 1, 2026 07:41
autoFocus opens the keyboard immediately on mount, which can block
UI elements before the screen finishes rendering. Replace it with a
ref-based focus triggered after a 300 ms delay, giving the navigation
transition time to complete on both iOS and Android.

- Add nameInputRef (useRef<TextInput>) to the name field
- Remove autoFocus prop from the name TextInput
- Focus the input programmatically after 300 ms in a useEffect
- Import useRef from React
…lity tracking

- Switch KeyboardAvoidingView behavior to 'padding' on iOS and
  undefined on Android (Android handles scroll natively)
- Track keyboard show/hide events with Keyboard listeners to set
  isKeyboardVisible state
- Apply extra bottom padding to ScrollView content when keyboard is
  open so all form fields remain reachable
- Import Keyboard from react-native
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 1, 2026

@senmalong Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

🔧 Add autoFocus handling improvements

1 participant