Skip to content

Document placing a text input's caret from PHP - #591

Open
simonhamp wants to merge 1 commit into
mainfrom
docs/text-input-selection
Open

simonhamp wants to merge 1 commit into
mainfrom
docs/text-input-selection

Conversation

@simonhamp

Copy link
Copy Markdown
Member

Documents the selection attribute on the text inputs from NativePHP/mobile-ui#189: where the caret goes, or what's selected, when your component changes the field's text. Keep this as a draft until #189 is merged and tagged.

On the Text Input page:

  • selection in the Content props, and selection(?int $start, ?int $end = null) in the fluent API.
  • A "Placing the caret" section under Caret and selection reporting. It has a mention-picker example that swaps the "@ja" being typed for the picked handle and puts the caret after it. It also gives the rules: code points, clamped, rounded to a character boundary on iOS. The field reads it only when it takes a new value from the component, never while the user types and not on mount. Set it back to null once the field has the text, and keep the attribute declared (null) so iOS doesn't rebuild the field and drop the keyboard. It's ignored on secure fields.
  • The existing bullet about a pushed value putting the caret at the end now mentions selection. A new bullet says a press sends any pending selection event first (also from fix "building your application for production" link #189).

The badges say mobile-ui 0.9, the next release. If #189 misses it, they need bumping.

The page renders locally and DocumentationRenderingTest passes.

🤖 Generated with Claude Code

Covers mobile-ui's new `selection` attribute on the text inputs: where
the caret goes, or what's selected, when the component changes the
field's text. Adds it to the props and the fluent API, a "Placing the
caret" section with a mention-picker example and its rules, and a note
that a press now sends any pending selection event first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simonhamp
simonhamp marked this pull request as ready for review October 29, 2026 13:49

This branch has not been deployed

No deployments
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.

1 participant