Skip to content

fix(TextInput,NumberInput): tapping the clear button brings up the iOS keyboard - #8183

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c08-clear-keyboard
Oct 24, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c08-clear-keyboard

Conversation

@vjeux

@vjeux vjeux commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

User impact

On an iPhone, tapping the clear button of a TextInput or NumberInput that is not focused empties the field and focuses it, but no keyboard comes up. The person has to tap the field again to type the replacement they cleared the field for.

Problem and solution fit

Since #5440, the clear button's pointer path focuses the field a frame later (requestAnimationFrame). iOS Safari raises its keyboard only for a focus made while handling the touch, so the later focus lands with no keyboard. #5440 deferred the focus to avoid a page jump to the top. preventScroll, which that change also added, is what prevents the jump; the deferral only broke the keyboard. This change keeps preventScroll and focuses inside the tap.

Expected behavior and authority

UIKit's clear button makes its field the first responder: in a UIKit app on iOS 26.2 the keyboard starts rising 75 ms after the lift. No current record says otherwise; #5440 is the regression history. Siblings: #8158 makes the same change in PanelSearchInput; #6425, #7690, #7910, #7940 (TextInput) and #5978, #8015 (NumberInput) touch the same files with other intents.

Smallest restoration

Two lines in each of TextInput and NumberInput: the pointer path calls focus({preventScroll: true}) directly instead of in the next frame. The keyboard and assistive-technology path (detail === 0) is unchanged, as is the clear button's preventDefault on pointerdown, which keeps a focused field focused. DateInput, TimeInput, DateTimeInput and FileInput have the same pattern; their lanes own them.

Evidence

Mobile Safari, iOS 26.2 (simulator), page scrolled 254 px, field unfocused with a value, one tap on its clear button:

keyboard page scroll
TextInput before none (viewport stays 714) stays 254
TextInput after up (viewport 714 → 377) stays 254
NumberInput before none stays 254
NumberInput after number pad (714 → 404) 254 → 266: Safari reveals the field the pad would cover

(removed: it showed the browser's chrome)

  • Regression tests: the pointer path focuses synchronously, with preventScroll, and without requestAnimationFrame. This replaces the test that pinned the deferral.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm vitest run on TextInput, NumberInput and Field: 15 files, 600 tests.
  • Core typecheck, eslint and prettier on touched files, check:changesets.
  • Mobile Safari on the iOS 26.2 simulator (iPhone 17 Pro): the four runs above, with visual viewport, focus and scroll events read from the page.

…S keyboard

The field took focus a frame after the tap (requestAnimationFrame), and iOS
Safari only raises its keyboard for a focus made while handling the touch,
so a field the tap reached unfocused ended up focused with no keyboard.
Focus inside the tap, still with preventScroll.
@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 24, 2026 10:11am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 24, 2026, 10:39 AM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

NumberInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1139 -
Complexity N/A Very High (171) -
TextInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 376 -
Complexity N/A Very High (68) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

46 of 494 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 26 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot 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.

This review recommends approval: focusing the field inside the tap brings the iOS keyboard back after a clear with no API change, and the new tests pin the in-tap timing. One suggestion: packages/core/src/DateInput/TouchDateField.tsx records that preventScroll alone did not stop an iOS jump to the top on that read-only field, so a sentence on why these editable inputs differ would keep the two explanations from contradicting each other; your iOS runs show no jump here.

[Automated review]

@cixzhang
cixzhang merged commit cd53c2d into meta:main Oct 24, 2026
63 checks passed
@vjeux
vjeux deleted the uikit/c08-clear-keyboard branch October 24, 2026 13:04

This branch was successfully deployed

1 active deployment
Preview — 94430eb7 Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants