Skip to content

fix: fire Ruby on_focus and on_blur on Cupertino Chip - #32

Merged
AdamMusa merged 2 commits into
codex/engine-initializationfrom
fix/cupertino-chip-focus-events
Oct 29, 2026
Merged

AdamMusa merged 2 commits into
codex/engine-initializationfrom
fix/cupertino-chip-focus-events

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Summary

Ruby's Chip (materials/chip_control.rb) declares on_focus, on_blur and autofocus. The Material renderer fires "focus" and "blur" from its FocusNode and reads autofocus. The Cupertino renderer (CupertinoChipControl in cupertino_content_controls.dart) did neither, so on iOS and macOS chip(on_focus:, on_blur:) never fired and autofocus was ignored.

Fix

The Cupertino chip's main CupertinoButton now:

  • reads autofocus;
  • fires "focus" and "blur" through CupertinoButton.onFocusChange.

Focus comes from keyboard traversal (iPad and macOS keyboards, Full Keyboard Access) or from autofocus. As on Material, the button is focusable only when it is interactive (on_click or on_select).

This touches a different hunk than #3 (delete_icon_tooltip), and they merge cleanly.

Tests

New test/widgets/ruby_chip_focus_events_test.dart, run on iOS and Android:

  • Tab focuses the chip and fires focus. Unfocusing fires blur.
  • autofocus: true fires focus on the first frame.

The iOS cases failed before the fix, with no events. The Android cases guard the existing Material behavior.

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

Wave-2 follow-up P1 (Chip)

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