Skip to content

Add a SearchTextChanged event so a non-Compose host can drive the search - #6

Merged
solcott merged 1 commit into
mainfrom
feature/search-text-event
Aug 14, 2026
Merged

Add a SearchTextChanged event so a non-Compose host can drive the search#6
solcott merged 1 commit into
mainfrom
feature/search-text-event

Conversation

@solcott

@solcott solcott commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Stack 2/4 — base chore/compose-1.12-rc01 (#5).

CountryListScreen.State exposes the search box as a TextFieldState, which is snapshot-backed
Compose Foundation state. A Compose UI binds it directly — that is the point of the type — but it has
no meaning to a host that is not a composition, and the SwiftUI app stacked above this is one: it owns
a plain Swift String.

SearchTextChanged is the seam. The presenter routes it through setTextAndPlaceCursorAtEnd, so the
TextFieldState stays the single source of truth and a Compose host sharing the presenter would not
see a stale search box. The test pins that second part specifically, not just that filtering works
— it asserts the TextFieldState ends up holding the same text.

Android, web and desktop are unaffected: they keep binding the TextFieldState and never send the
event.

Why this is its own PR

It is the only change to code the other three apps share, and it is additive and independently
tested. Worth reviewing without the Apple diff on top of it.

Verification

ktfmtCheck and :presenter:jvmTest on this branch alone.

🤖 Generated with Claude Code

@solcott
solcott force-pushed the feature/search-text-event branch 2 times, most recently from 2f07270 to e942520 Compare August 14, 2026 15:48
Base automatically changed from chore/compose-1.12-rc01 to main August 14, 2026 16:04
CountryListScreen.State exposes the search box as a TextFieldState, which is
snapshot-backed Compose Foundation state. A Compose UI binds it directly — that is
the point of the type — but it has no meaning to a host that is not a composition,
and the SwiftUI app is one: it owns a plain Swift String.

SearchTextChanged is the seam. The presenter routes it through
setTextAndPlaceCursorAtEnd, so the TextFieldState stays the single source of truth
and a Compose host sharing the presenter would not see a stale search box. The test
pins that second part specifically, not just the filtering.

This is the only change the other three apps share; they keep binding the
TextFieldState and never send the event.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@solcott
solcott force-pushed the feature/search-text-event branch from e942520 to 74e24eb Compare August 14, 2026 16:04
@solcott
solcott merged commit d775e03 into main Aug 14, 2026
@solcott
solcott deleted the feature/search-text-event branch August 14, 2026 16:14
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