Browse API 1 documentation
GroveAPI 1preview

grove.composer.requestFocus()

Hand an already-focused message composer to a utility text field.

Mango 3.1+View Markdown

Ask Mango to hand focus from its native message composer to a text field in a composer utility.

Signature

ts
grove.composer.requestFocus(elementID: string): void

Availability

An additive API 1 method in newer Mango 3.1 builds. Feature-detect it on older hosts. Only a mounted composer utility’s main document can use it; other surfaces and settings pages cannot request the handoff. No additional capability is required.

Parameters

Parameter Required Description
elementID Yes The exact HTML id of a visible, enabled, editable text input, textarea, or contenteditable element. Not a CSS selector. Nonempty, at most 256 UTF-8 bytes.

Return value

Returns undefined. This is a best-effort request, not a promise that focus was granted. Invalid IDs throw before posting; native focus failures are logged in the Grove console/log.

Behavior

Call after the field exists. Mango queues an early request until the document and native panel are ready. One initial handoff is attempted per presentation; this is not an API for repeatedly stealing focus between fields.

On iPhone and iPad, Mango transfers focus only if its native message composer was focused when the panel opened and still owns focus when the request is handled. Opening a utility with the keyboard hidden does not summon it. If the user dismisses the keyboard or moves to another field while the utility loads, the request does not steal focus. An attached hardware keyboard follows the same focused-composer policy.

On macOS, the key window’s current focus can transfer to the utility, provided it has not changed since presentation. Normal clicks and keyboard navigation inside the utility remain available on every platform.

Closing a utility opened from a focused composer restores the draft’s focus. Completing a result returns to the native draft for review. Neither operation sends a message.

Use at least 16px text on touch-device inputs to avoid iOS’s automatic focus zoom. Do not disable user zoom through viewport restrictions.

Example

html
<input id="query" type="search" placeholder="Search animated GIFs…">
js
grove.composer.requestFocus?.('query')

On older hosts, leave mobile focus to an explicit tap. Unconditional input.focus() is not a substitute for native keyboard handoff.

See grove.composer.close(), grove.composer.complete(), and Composer utilities.