Introduce HASearchField#7151
Conversation
ebb8d64 to
9ff5691
Compare
ae1eaca to
048ca8d
Compare
9ff5691 to
6a124f9
Compare
048ca8d to
8e2d83b
Compare
8e2d83b to
85fa87a
Compare
There was a problem hiding this comment.
Pull request overview
This pull request introduces a reusable Compose HASearchField component (built on HATextField) that encapsulates debounced search behavior behind a SearchFieldState, along with interaction and screenshot tests, and a debug-catalog entry to showcase the component.
Changes:
- Added
HASearchFieldcomposable andSearchFieldState+rememberSearchFieldStatehelper to centralize debounced search input behavior. - Added Robolectric Compose UI tests validating label/clear-icon behavior and debounce timing semantics.
- Added screenshot tests (light/dark + with/without leading icon) and wired the component into the debug UI catalog.
Reviewed changes
Copilot reviewed 4 out of 10 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| common/src/main/kotlin/io/homeassistant/companion/android/common/compose/composable/HASearchField.kt | Adds the debounced search field composable and its state holder/helper. |
| common/src/test/kotlin/io/homeassistant/companion/android/common/compose/composable/HASearchFieldTest.kt | Adds interaction tests for debounce behavior, label visibility, and clearing. |
| common/src/screenshotTest/kotlin/io/homeassistant/companion/android/compose/composable/HASearchFieldScreenshotTest.kt | Adds screenshot coverage for empty/filled states and optional leading icon. |
| app/src/debug/kotlin/io/homeassistant/companion/android/developer/catalog/HAUserInputScreen.kt | Showcases HASearchField in the developer catalog. |
jpelgrom
left a comment
There was a problem hiding this comment.
Thanks for extracting this. I kind of liked remember being internal in the original PR but this also works and matches Compose patterns so no objection.
|
With changes from suggestion above you get: search.mp4Without is already visible in your screenshot in the description, IME has an enter (new line) key. |
Co-authored-by: Joris Pelgröm <jpelgrom@users.noreply.github.com>
jpelgrom
left a comment
There was a problem hiding this comment.
Thanks for accepting my changes :)
Test Results 321 files 325 suites 15m 4s ⏱️ For more details on these failures, see this check. Results for commit b2ee8c0. |
Summary
Extracted the debounce search logic within a
HASearchField, this was initially made in #6567 by @danielgomezrico. Since I'm currently redoing the EntityPicker I took the opportunity to extract it into a smaller PR. I've also added a small state object and a remember helper on top of tests.It's built on top of our existing
HATextField, it can be extended later.Checklist
Screenshots
Any other notes
Based on #7149