Revert "Associate the room address field helper text and error with the field"

This reverts commit d4e7cbfdbe.
This commit is contained in:
Mauro Romito
2026-06-22 13:17:23 +02:00
parent d4e7cbfdbe
commit 173a927bf8
3 changed files with 5 additions and 19 deletions
@@ -12,23 +12,12 @@ import SwiftUI
struct EditRoomAddressListRow: View { struct EditRoomAddressListRow: View {
@Binding var aliasLocalPart: String @Binding var aliasLocalPart: String
var serverName: String var serverName: String
/// The error to display, if any. Also associated with the field for VoiceOver. var shouldDisplayError: Bool
var errorDescription: String?
/// The section's helper text, associated with the field for VoiceOver.
var footerText: String?
private var fullAddress: String { private var fullAddress: String {
"#\(aliasLocalPart):\(serverName)" "#\(aliasLocalPart):\(serverName)"
} }
/// Associates the helper text and any error with the field, as they're otherwise
/// only shown in a separate section footer.
private var accessibilityHint: String {
[L10n.a11yEditRoomAddressHint(fullAddress), footerText, errorDescription]
.compactMap { $0 }
.joined(separator: "\n")
}
var body: some View { var body: some View {
ListRow(kind: .custom { ListRow(kind: .custom {
HStack(spacing: 0) { HStack(spacing: 0) {
@@ -45,7 +34,7 @@ struct EditRoomAddressListRow: View {
.foregroundStyle(.compound.textPrimary) .foregroundStyle(.compound.textPrimary)
.padding(.horizontal, 8) .padding(.horizontal, 8)
.accessibilityLabel(L10n.a11yAddress) .accessibilityLabel(L10n.a11yAddress)
.accessibilityHint(accessibilityHint) .accessibilityHint(L10n.a11yEditRoomAddressHint(fullAddress))
Text(":\(serverName)") Text(":\(serverName)")
.font(.compound.bodyLG) .font(.compound.bodyLG)
.foregroundStyle(.compound.textSecondary) .foregroundStyle(.compound.textSecondary)
@@ -53,7 +42,7 @@ struct EditRoomAddressListRow: View {
} }
.padding(ListRowPadding.textFieldInsets) .padding(ListRowPadding.textFieldInsets)
.environment(\.layoutDirection, .leftToRight) .environment(\.layoutDirection, .leftToRight)
.errorBackground(errorDescription != nil) .errorBackground(shouldDisplayError)
}) })
} }
} }
@@ -193,8 +193,7 @@ struct CreateRoomScreen: View {
Section { Section {
EditRoomAddressListRow(aliasLocalPart: aliasBinding, EditRoomAddressListRow(aliasLocalPart: aliasBinding,
serverName: context.viewState.serverName, serverName: context.viewState.serverName,
errorDescription: context.viewState.aliasErrors.errorDescription, shouldDisplayError: context.viewState.aliasErrors.errorDescription != nil)
footerText: L10n.screenCreateRoomRoomAddressSectionFooter)
.focused($focus, equals: .alias) .focused($focus, equals: .alias)
.id(Focus.alias) .id(Focus.alias)
} header: { } header: {
@@ -16,9 +16,7 @@ struct EditRoomAddressScreen: View {
Form { Form {
Section { Section {
EditRoomAddressListRow(aliasLocalPart: $context.desiredAliasLocalPart, EditRoomAddressListRow(aliasLocalPart: $context.desiredAliasLocalPart,
serverName: context.viewState.serverName, serverName: context.viewState.serverName, shouldDisplayError: context.viewState.aliasErrors.errorDescription != nil)
errorDescription: context.viewState.aliasErrors.errorDescription,
footerText: L10n.screenEditRoomAddressRoomAddressSectionFooter)
.onChange(of: context.desiredAliasLocalPart) { _, newAliasLocalPart in .onChange(of: context.desiredAliasLocalPart) { _, newAliasLocalPart in
context.desiredAliasLocalPart = newAliasLocalPart.lowercased() context.desiredAliasLocalPart = newAliasLocalPart.lowercased()
} }