fix: stabilize Android label picker keyboard - #2303
Open
Mayank-2-16 wants to merge 1 commit into
Open
Conversation
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.
PR Description: Fix Android Label Picker Keyboard Flicker
Fixes: #2260
Summary
This PR fixes an Android-specific issue where creating labels from the page Details panel was unreliable.
When tapping Add label on Android, the label picker opened and the soft keyboard could briefly appear, then immediately disappear. This made it difficult or impossible to type a new label.
The issue was caused by the picker opening from a button while a newly mounted input inside a Mantine
Popovertried to autofocus. On Android, the soft keyboard changes viewport geometry, which can disturb floating UI positioning and focus state.No issue was filed for this bug. This PR is opened directly after reproducing and analyzing the Android keyboard behavior.
Bug / Problem
The Add label flow worked on desktop but was unstable on Android.
Steps to reproduce:
The label API was not the problem. The failure happened before label creation, while trying to focus the picker input.
Expected Behavior
On Android:
On desktop:
Actual Behavior Before This PR
The picker input used unconditional autofocus after being mounted inside a newly opened popover.
That produced this fragile mobile sequence:
Root Cause
The label picker was using desktop-friendly autofocus behavior for all devices.
Android is sensitive to programmatic focus that happens after tapping a separate button, especially when the focused input is mounted inside a floating layer. The soft keyboard can resize the viewport, which affects popover positioning and can cause focus loss.
Relevant references:
https://developer.chrome.com/blog/viewport-resize-behavior/https://mantine.dev/core/popover/https://developer.mozilla.org/en-US/docs/Web/API/VirtualKeyboard_APIChanges Made
apps/client/src/features/label/components/labels-section.tsxuseMediaQuery("(pointer: coarse)").trapFocuson touch/coarse pointer devices.hideDetached={false}so keyboard viewport changes do not hide the popover.apps/client/src/features/label/components/label-picker.tsxautoFocusInputandinputRefprops.autoFocuswith conditionaldata-autofocus.Why This Approach
The reliable mobile path is for the keyboard to open from a direct tap on an input. However, the existing UI is built around a separate Add label button that opens a popover, and the input is mounted inside that popover afterward.
On Android, that button-to-new-input flow is fragile when it also tries to programmatically focus the newly mounted input. The soft keyboard changes viewport geometry, and that can cause focus/popover state to bounce, which is why the keyboard appears briefly and then closes.
This PR keeps the fix intentionally small and targeted:
A more complete one-tap mobile solution is possible, but it is a larger UI refactor. That version would make the Add label action become or contain the actual input target, so the user's first tap lands directly on an editable field. That would likely require moving the search input out of the popover dropdown and into the popover target itself, then turning the dropdown into only the suggestion/create list.
That larger refactor has a wider review surface:
For this PR, I fixed the Android keyboard flicker with the smallest safe change. The larger one-tap input-target redesign is better treated as a follow-up UX improvement rather than bundled into this focused bug fix.
Verification
Ran:
Result:
The build emitted existing warnings about pnpm config, deprecated
advancedChunks, and large chunks. These warnings are unrelated to this change.Manual Testing Checklist
Risk
Risk is low to moderate.
Main tradeoff:
This tradeoff is intentional because it avoids the unstable Android keyboard flash and keeps the fix minimal.