Skip to content

fix: render Semantics content and honor Ruby semantics keys - #2

Merged
AdamMusa merged 2 commits into
codex/engine-initializationfrom
fix/semantics-content-and-events
Oct 28, 2026
Merged

AdamMusa merged 2 commits into
codex/engine-initializationfrom
fix/semantics-content-and-events

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Problem

Ruby's SemanticsControl (packages/ruflet_core/lib/ruflet_ui/ruflet/ui/controls/shared/semantics_control.rb) defines the wire keys. semantics.dart read different names, so Flutter received nothing for several of them:

Ruby sends Dart read Effect
content nothing (Semantics had no child:) The wrapped control was never rendered. semantics(text("Hi"), label: ...) showed nothing on either design
textfield text_field Dropped
hint_text hint Dropped
on_tap_hint_text on_tap_hint Dropped
on_long_press_hint_text on_long_press_hint Dropped
focus focused Dropped
on_tap on_click, fired "click" on_tap never fired
on_long_press on_dismiss, fired "dismiss" (copy-paste bug) on_long_press never fired. A long press ran the on_dismiss handler
on_double_tap nothing Never fired

QA finding #1, #2, #3.

Fix

  • Build control.buildWidget("content") and pass it as the Semantics child. With no content, the control still renders as a bare semantics node, as before.
  • Read the Ruby spellings textfield, hint_text, on_tap_hint_text, on_long_press_hint_text and focus.
  • onTap now checks on_tap and fires "tap". onLongPress now checks on_long_press and fires "long_press".
  • on_double_tap fires "double_tap". Flutter has no double-tap SemanticsAction, so the content is wrapped in a widgets-layer GestureDetector(onDoubleTap:), only when on_double_tap is set. It adds no Material or Cupertino widgets.
  • I checked every other on_* keyword in Ruby's KEYWORDS against the Dart wiring. They were already correct, and the test now covers them: increase, decrease, dismiss, scroll_left/right/up/down, copy, cut, paste, did_gain/lose_accessibility_focus, move_cursor_forward/backward_by_character (passes the bool), set_text (passes the text). The *_hint_text keywords are strings, not handlers.

The same renderer serves both designs. It uses only package:flutter/widgets.dart, so Material and Cupertino behave the same way.

Tests

New packages/ruflet/test/widgets/ruby_semantics_test.dart. Each case runs on a Cupertino target (iOS, CupertinoApp) and a Material target (Android, MaterialApp):

  • The content child renders inside SemanticsControl with a non-zero size.
  • The Ruby keys show up in the semantics tree (tester.getSemantics + isSemantics): isTextField, isFocused, hint, onTapHint, onLongPressHint, and the tap and long-press actions.
  • Each Ruby on_* event fires under its own name. The test runs each SemanticsAction and records triggerEvent through a test backend, as the matrix test and QA repro do. A real double tap on the content fires double_tap.
  • The old Flet spellings (hint, text_field, focused, on_click) are ignored, and on_dismiss no longer captures long presses.

Results (Flutter 3.41.2):

  • Before the fix: ruby_semantics_test.dart gave +0 -8: Some tests failed.
  • After the fix: +8: All tests passed!. The QA repro qa_wire_key_repro_test.dart --name Semantics gave +4: All tests passed!
  • verify_pr.sh <worktree> "":
    PASS engine:ruflet flutter test         +703: All tests passed!
    PASS engine:ruflet analyze              No issues found!
    RESULT: PASS
    

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