Skip to content

Enable IME for text inputs focussed before first layout - #843

Open
nicoburns wants to merge 1 commit into
mainfrom
devin/1788875289-ime-autofocus
Open

Enable IME for text inputs focussed before first layout#843
nicoburns wants to merge 1 commit into
mainfrom
devin/1788875289-ime-autofocus

Conversation

@nicoburns

@nicoburns nicoburns commented Sep 8, 2026

Copy link
Copy Markdown
Member

Summary

With a CJK input source active, typing into an input that is focussed at startup (autofocus, or onmounted → set_focus) produced raw ASCII until the input was blurred and re-focussed.

Cause: Node::focus decided "is this a text input?" via element_data().text_input_data().is_some(), but TextInputData is only created during layout construction (create_text_editor in layout/construct.rs). Autofocus runs at mutation-flush time, before the first resolve(), so set_ime_enabled(true) was never called.

Changes (blitz-dom):

  • ElementData::is_text_input() — tag/type-based check (same set as construct.rs), independent of layout. Node::focus/blur now use it to enable/disable the IME.
  • Node::ime_cursor_area() -> Option<(x, y, w, h)> returns None before layout instead of reading a not-yet-computed final_layout.
  • BaseDocument::sync_ime_cursor_area() is called at the end of resolve() after layout: it reports the focussed text input's content box to the shell, deduplicated against last_ime_cursor_area so it only fires when the area actually changes (including after the first layout of an autofocussed input, or when the input moves due to relayout).

Adds a unit test with a recording ShellProvider covering focus-before-layout → set_ime_enabled(true), area reported once after resolve, no re-report on unchanged layout, and set_ime_enabled(false) on blur.

Found during the macOS smoke test of #614 (pre-existing on main). On macOS the cursor area is currently still discarded by winit because Blitz enables the IME without the cursor_area capability; that is fixed in a separate PR.

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/a737411590c54bbb833aa9167f89ac51
Open in Devin Desktop: https://dioxus.staging.devinenterprise.com/desktop/session/a737411590c54bbb833aa9167f89ac51?variant=devin-insiders
Requested by: @nicoburns

WPT results

No changes in test results compared to main.

Generated by the WPT workflow.

@staging-devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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