From 0b079e3df63a95f2a7d592fa51f9dbede909eddf Mon Sep 17 00:00:00 2001 From: Bojie Li Date: Sun, 6 Sep 2026 23:50:28 +0800 Subject: [PATCH] settings: the example box stops claiming to be empty while holding text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Empty — however the model would write it" was passed as the TextField's *title*, not its placeholder. A Form renders a title as a label and keeps it there whatever the field contains, so on macOS the sentence sat in the label column above a box with text in it, describing the opposite of what was on screen. Nothing about it was conditional — it is a string literal, so it said "Empty" whether or not the box was. It moves to `prompt:`, which is the placeholder: shown only while the box is empty, which is the one moment the sentence is true. iOS renders a Form TextField's title inside the field, which is why the identical line looked correct there — the same code, saved by a platform convention rather than by saying what it meant. Changed to match, so neither file depends on where a platform decides to put a label. Verified in the running app rather than by reasoning about SwiftUI: with text in the box the label is gone, and with the box cleared the sentence appears inside it in grey with Clear correctly disabled. On iOS, testAPresetFillsTheExampleBoxAndPersists passes against the simulator — the accessibility identifier is untouched, so the box is still found and a preset still fills it. Co-Authored-By: Claude Opus 5 (1M context) --- Sources/DoNotTypeApp/SettingsView.swift | 12 ++++++++++-- ios/App/SettingsView.swift | 11 +++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Sources/DoNotTypeApp/SettingsView.swift b/Sources/DoNotTypeApp/SettingsView.swift index 0d9202f..a2791c3 100644 --- a/Sources/DoNotTypeApp/SettingsView.swift +++ b/Sources/DoNotTypeApp/SettingsView.swift @@ -1351,10 +1351,18 @@ private struct TranscriptStyleSection: View { .disabled(model.dictationExample.isEmpty) } } + // The sentence goes in `prompt:`, not in the title. A TextField's first argument is + // its *label*, which a Form renders beside or above the field and keeps there whatever + // the field contains — so a title reading "Empty — …" sat above a box with text in it + // and flatly contradicted the thing it was describing. `prompt:` is the placeholder: + // it shows only while the box is empty, which is the one moment the sentence is true. TextField( - "Empty — however the model would write it", - text: $model.dictationExample, axis: .vertical + "Your example", + text: $model.dictationExample, + prompt: Text("Empty — however the model would write it"), + axis: .vertical ) + .labelsHidden() .lineLimit(4...12) .textFieldStyle(.roundedBorder) .accessibilityIdentifier("dictation-example") diff --git a/ios/App/SettingsView.swift b/ios/App/SettingsView.swift index 8c9e21f..09f7865 100644 --- a/ios/App/SettingsView.swift +++ b/ios/App/SettingsView.swift @@ -279,10 +279,17 @@ struct SettingsView: View { .disabled(model.dictationExample.isEmpty) .accessibilityIdentifier("preset-clear") } + // `prompt:` rather than the title, to say what this string is instead of relying on + // the platform to guess. iOS happens to render a Form TextField's title inside the + // field, so this looked right here while the identical line on macOS put "Empty — …" + // in the label column, where it stayed above a box with text in it. TextField( - "Empty — however the model would write it", - text: $model.dictationExample, axis: .vertical + "Your example", + text: $model.dictationExample, + prompt: Text("Empty — however the model would write it"), + axis: .vertical ) + .labelsHidden() .lineLimit(4...12) .accessibilityIdentifier("dictation-example") Text(