Skip to content

fix(search-bar): style the typed text and drive Cancel from focus - #31

Open
romchornyi wants to merge 1 commit into
masterfrom
fix/searchbar-text-style
Open

romchornyi wants to merge 1 commit into
masterfrom
fix/searchbar-text-style

Conversation

@romchornyi

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

Closes #26.

SearchBar styled only its placeholder. The text you type fell back to the system body font (17pt) in .primary, while the placeholder is .subhead (15pt). So the line changed size on the first keystroke and did not use the design-system colour. dashwallet-ios uses this field in LocalCurrencyView and SelectCoinView.

What was done?

  • Typed text gets .dashFont(.subhead) and Color.dash.primaryText. These are the same modifiers AddressFieldView uses, so the two fields render typed text the same way. .dashFont adds about 1pt of line-height padding, which fits inside the 40pt field.
  • Cancel button:
    • It is driven by @FocusState isFocused directly. The @State isEditing copy is gone, along with the onAppear sync, the onChange and both withAnimation blocks.
    • One .animation(_:value: isFocused) now covers what was animated three times.
    • The removed onAppear sync never had any effect: @FocusState is always false on first appearance, and the host cannot focus this field from outside.
  • Previews: empty, typed, and typed in dark mode.
  • Docs: docs/buttons-and-inputs.md describes the focus-driven Cancel button and the typed-text style.

How Has This Been Tested?

  • swift build, swift test and xcodebuild build-for-testing for the iOS Simulator are clean, with no warnings.
  • Rendered on an iOS 27 simulator, master and this branch side by side, in light and dark, in four states: empty, focused, typed, typed + focused. On master the typed text is visibly larger than the placeholder; on this branch they match. The field stays vertically centred, Cancel appears only while focused, and dark mode uses primaryText.
  • A focus-sequence review covered gaining focus by tap, hardware keyboard and VoiceOver, and losing it by Cancel, a tap outside, or the sheet or host going away. Each sequence ends with the same Cancel state as before.
  • dashwallet-ios develop (LocalCurrencyView, SelectCoinView) sets no font or colour on SearchBar, so nothing there is overridden.

Breaking Changes

None. The public API is unchanged.

One behaviour to know: typed text is now a fixed 15pt, like every Font.dash token, the placeholder and AddressFieldView. Before, it was the system body style, which scaled with Dynamic Type. The docs say so.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

🤖 Generated with Claude Code

The field styled only its prompt. Typed text fell back to the system
body font in `.primary`, so the line grew from 15pt to 17pt on the first
keystroke and did not use the design-system colour. It now uses
`.dashFont(.subhead)` and `Color.dash.primaryText`, the same modifiers as
`AddressFieldView`.

The Cancel button followed a `@State` copy of the focus state, synced in
`onAppear` and `onChange`, and each focus change was animated three times.
It now reads `isFocused` directly, with one `.animation(value:)`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

SearchBar: style the typed text and drop the isEditing mirror of the focus state

1 participant