fix(desktop): make error messages selectable so users can copy them
Several user-visible error messages on Desktop are rendered with plain `Text` composables, which means they can't be selected or copied. That makes it awkward to share an error in a bug report or paste a hex error string into a search. Wrap the error text in `SelectionContainer` at the canonical sites: - `commons.ui.components.LoadingState`: wrap the description in `EmptyState` and the message in `ErrorState`. `EmptyState` is reused as the in-feed error renderer (e.g. 'Error loading feed' with the underlying error in `description`), so this covers feed/loading errors across screens that use these helpers. - `ComposeNoteDialog`: wrap the validation error and the upload error in the compose-note dialog. - `auth/LoginCard` (Nostr Connect): wrap the connection error. - `auth/KeyInputField`: wrap the supporting-text error so the inline message under the nsec input field can be copied. No visual changes \u2014 `SelectionContainer` does not affect layout or styling. Selection works on Compose Desktop (mouse drag) and on Android (long-press) without further changes.
This commit is contained in:
+15
-10
@@ -31,6 +31,7 @@ import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
@@ -251,20 +252,24 @@ fun ComposeNoteDialog(
|
||||
|
||||
errorMessage?.let { error ->
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
error,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
SelectionContainer {
|
||||
Text(
|
||||
error,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
uploadState.error?.let { error ->
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Text(
|
||||
"Upload error: $error",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
SelectionContainer {
|
||||
Text(
|
||||
"Upload error: $error",
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
+6
-1
@@ -22,6 +22,7 @@ package com.vitorpamplona.amethyst.desktop.ui.auth
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.IconButton
|
||||
@@ -85,7 +86,11 @@ fun KeyInputField(
|
||||
isError = errorMessage != null,
|
||||
supportingText =
|
||||
errorMessage?.let {
|
||||
{ Text(it, color = MaterialTheme.colorScheme.error) }
|
||||
{
|
||||
SelectionContainer {
|
||||
Text(it, color = MaterialTheme.colorScheme.error)
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
+8
-5
@@ -30,6 +30,7 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
@@ -254,11 +255,13 @@ private fun NostrConnectContent(
|
||||
val clipboardManager = LocalClipboard.current
|
||||
|
||||
if (errorMessage != null) {
|
||||
Text(
|
||||
errorMessage!!,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
SelectionContainer {
|
||||
Text(
|
||||
errorMessage!!,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
)
|
||||
}
|
||||
Spacer(Modifier.height(12.dp))
|
||||
Button(onClick = {
|
||||
errorMessage = null
|
||||
|
||||
Reference in New Issue
Block a user