fix(core): dismiss keyboard after Locator.fill()#214
Conversation
|
Warning Review limit reached
More reviews will be available in 22 minutes and 24 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughAn optional 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/driver-mobilecli/src/driver.ts`:
- Around line 424-430: The dismissKeyboard() implementation in driver.ts is too
aggressive because it always sends BACK on Android and return on iOS, which can
change navigation or field contents instead of only hiding the soft keyboard.
Update the Driver.dismissKeyboard method to use a real keyboard-dismiss path or
add a keyboard-visible check before calling pressButton('BACK') or
pressKeys(['return']), so Locator.fill() does not introduce unintended side
effects.
In `@packages/driver-mobilenext/src/driver.ts`:
- Around line 417-423: The dismissKeyboard() implementation in driver.ts is too
aggressive because it always sends BACK on Android and return on iOS, which can
trigger navigation or input actions instead of only hiding the keyboard. Update
dismissKeyboard() to use a true “dismiss if open” approach in the Driver class,
and avoid relying on pressButton('BACK') or pressKeys(['return']) as
unconditional fallbacks. Make sure the behavior used by Locator.fill() only
closes the keyboard when present and does not change app state or field
contents.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bb84d3b9-3f50-4715-bb62-897bd6b28ca2
📒 Files selected for processing (4)
packages/driver-mobilecli/src/driver.tspackages/driver-mobilenext/src/driver.tspackages/mobilewright-core/src/locator.tspackages/protocol/src/driver.ts
Related issues
This PR implements:
Locator.fill()on mobile #154 - full design discussion for this changeSummary
Locator.fill()now automatically dismisses the soft keyboard after text entry on mobile, making follow-up interactions (especially taps on elements below the focused input) reliable without requiring an explicit keyboard dismissal step.The problem this solves
After calling
.fill()on an input, the soft keyboard stays open. On Android this can cover interactive elements lower on the screen, such as submit buttons. The next.tap()may then hit the keyboard area or keep focus on the currently active input instead of activating the intended control.The existing workaround (
screen.goBack()after every fill) adds boilerplate and is easy to forget, leading to flaky tests.What this PR does
packages/protocol/src/driver.tsdismissKeyboard?(): Promise<void>method to theMobilewrightDriverinterface. Optional so drivers without keyboard support can simply omit it.packages/driver-mobilecli/src/driver.tsandpackages/driver-mobilenext/src/driver.tsdismissKeyboard()with a safety check:backkey event (keyboard-specific, not navigation)Donekey event (standard keyboard dismiss action)packages/mobilewright-core/src/locator.tsLocator.fill()now callsdriver.dismissKeyboard?.()afterdriver.typeText()completes, enabled by default.fill('text', { dismissKeyboard: false })for users who want the keyboard to remain open.e2e/src/android/facebook.keyboard.test.tswait(1000)and commented-outgoBack()workaround.Test plan
npm run build- clean (tsc -b)npm run lint- clean (tsc --noEmit && eslint .)npx playwright test packages/mobilewright-core/src/locator.test.ts- 49/49 passingdismissKeyboard: true): keyboard dismissed -> tap succeedsdismissKeyboard: false): keyboard stays open -> tap fails -> confirms fix workspressKeys(['Done'])) was not verified on a real device. The reviewer should confirm this dismisses the keyboard correctly on iOS before merging.Backwards compatibility
dismissKeyboard?()on driver interfacedismissKeyboard()with focused-input checkfill()auto-dismisses keyboard{ dismissKeyboard: false }fill()signature widened withdismissKeyboard?: booleanFiles changed