Skip to content

fix: honor Ruby trailing and semantic_label on MenuItemButton - #5

Merged
AdamMusa merged 2 commits into
codex/engine-initializationfrom
fix/menu-item-button-trailing
Oct 28, 2026
Merged

AdamMusa merged 2 commits into
codex/engine-initializationfrom
fix/menu-item-button-trailing

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Summary

Ruby's MenuItemButton (materials/menuitembutton_control.rb) declares semantic_label, a string, and trailing, a child control. An example is Ruflet.menu_item_button("Save", semantic_label: "Save file", trailing: Ruflet.icon(...)). The Dart side read different keys:

  • material_menu_item_button.dart read semantics_label and buildWidget("trailing_icon").
  • cupertino_navigation_controls.dart (CupertinoMenuItemButtonControl) read buildWidget("trailing_icon") and ignored the semantics label.

So the trailing widget was never rendered on either platform, and the accessibility label was dropped.

Fix

  • Material: semanticsLabel now reads semantic_label, and trailingIcon now reads buildWidget("trailing").
  • Cupertino: the trailing child now reads buildWidget("trailing"). When semantic_label is set, the button's label row is wrapped in Semantics(label:, excludeSemantics: true). This mirrors what Flutter's MenuItemButton.semanticsLabel does, and the CupertinoButton keeps its button and tap semantics.

The remaining "trailing_icon" and "semantics_label" readers belong to other controls (Dropdown, DropdownOption, CupertinoContextMenuAction, Text, Icon, ProgressBar/Ring, Checkbox, ...), and Ruby really sends those spellings there. They are left unchanged.

Tests

New test/widgets/ruby_menu_item_button_keys_test.dart, run on iOS (Cupertino) and Android (Material). All 4 tests failed before the fix.

  • Sends trailing: Text("Ctrl+S") and checks that the trailing text is rendered after the "Save" label.
  • Sends semantic_label: "Save file" and checks for a Semantics widget with that label, plus find.bySemanticsLabel("Save file"). On Material it also checks MenuItemButton.semanticsLabel and trailingIcon.

verify_pr.sh: flutter test +699, all passed (695 baseline + 4 new). flutter analyze lib test found no issues. Flutter 3.41.2.

QA finding #11

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