From c1d2efe112cd5d5f88aabdb773894811399d6bf3 Mon Sep 17 00:00:00 2001 From: enricobuehler Date: Wed, 29 Jul 2026 10:11:00 +0200 Subject: [PATCH] fix(client/apple): the Name field didn't say it was the name either MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same cause as the MAC one, and it deserved the same fix rather than another one-off: on iOS a TextField's title becomes an accessibility label the moment a prompt exists and nothing is drawn, so "Optional — e.g. Living Room" was the whole of what the field said about itself. The prompt is now built per platform. macOS draws the title as a leading label, so its prompt only hints at the value; iOS has no label to lean on, so the prompt names the field too. One string for both leaves you either a Mac panel that says everything twice — which is what the MAC field started doing in the last commit — or a phone form of unlabelled boxes. Co-Authored-By: Claude Opus 5 (1M context) --- .../PunktfunkClient/Home/AddHostSheet.swift | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/clients/apple/Sources/PunktfunkClient/Home/AddHostSheet.swift b/clients/apple/Sources/PunktfunkClient/Home/AddHostSheet.swift index 8a24862d..1b505f55 100644 --- a/clients/apple/Sources/PunktfunkClient/Home/AddHostSheet.swift +++ b/clients/apple/Sources/PunktfunkClient/Home/AddHostSheet.swift @@ -44,6 +44,21 @@ struct AddHostSheet: View { @State private var editingField: EditField? #endif + /// A field's placeholder, which is not the same job on both platforms. + /// + /// macOS draws a `TextField`'s title as a leading label, so the prompt only has to hint at the + /// VALUE. On iOS that title becomes an accessibility label the moment a prompt exists and + /// nothing is drawn — the prompt is the field's entire visible identity, so it has to name the + /// field as well as hint at it. Writing one string for both leaves you a Mac panel that says + /// everything twice or a phone form of unlabelled boxes. + private static func prompt(touch: String, desktop: String) -> Text { + #if os(macOS) + Text(desktop) + #else + Text(touch) + #endif + } + private var isEditing: Bool { existing != nil } private var actionTitle: String { isEditing ? "Save" : "Add Host" } private var canSave: Bool { !address.trimmingCharacters(in: .whitespaces).isEmpty } @@ -113,16 +128,18 @@ struct AddHostSheet: View { #else VStack(spacing: 0) { Form { - TextField("Name", text: $name, prompt: Text("Optional — e.g. Living Room")) + TextField( + "Name", text: $name, + prompt: Self.prompt( + touch: "Name (optional, e.g. Living Room)", + desktop: "Optional — e.g. Living Room")) TextField("Address", text: $address, prompt: Text("IP or hostname")) TextField("Port", value: $port, format: .number.grouping(.never)) - // The PROMPT is the only thing on show here on iOS (a field's title is its - // accessibility label once a prompt is given), so it has to name the field - // itself — "Wake-on-LAN — auto-filled when known" read as if that were the - // value being asked for. TextField( "MAC address", text: $mac, - prompt: Text("MAC address (for Wake-on-LAN, optional)")) + prompt: Self.prompt( + touch: "MAC address (for Wake-on-LAN, optional)", + desktop: "For Wake-on-LAN, optional")) .autocorrectionDisabled() #if os(iOS) .textInputAutocapitalization(.never)