Skip to content

Commit

Permalink
fixed property value edit TextField to preserve committed value.
Browse files Browse the repository at this point in the history
  • Loading branch information
atsushieno committed Mar 6, 2024
1 parent fe5995d commit f20c782
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,16 @@ fun PropertyValueEditor(isLocalEditor: Boolean,
}

if (isTextRenderable) {
// FIXME: we have state loss problem here, value vanishes after "Commit changes"
val bodyText = MidiCIConverter.decodeASCIIToString(body.toByteArray().decodeToString())
var text by remember { mutableStateOf(bodyText) }
if (resetState)
text = bodyText
if (isEditable) {
Row(verticalAlignment = Alignment.CenterVertically) {
Checkbox(editing, { editing = !editing })
Text("edit")
}
if (editing) {
var text by remember { mutableStateOf(bodyText) }
var partial by remember { mutableStateOf("") }
if (resetState) {
text = bodyText
Expand Down Expand Up @@ -311,12 +312,12 @@ fun PropertyValueEditor(isLocalEditor: Boolean,
PropertyEncodingSelector(metadata?.encodings ?: listOf(), selectedEncoding ?: "", onSelectionChange = { selectedEncoding = it.ifEmpty { null } })
} else {
showRefreshAndSubscribeButton()
PropertyEditorTextField(bodyText, readOnly = true)
PropertyEditorTextField(text, readOnly = true)
}
} else {
Text("read-only")
showRefreshAndSubscribeButton()
PropertyEditorTextField(bodyText, readOnly = true)
PropertyEditorTextField(text, readOnly = true)
}
} else {
Text("MIME type '$mediaType' not supported for editing")
Expand Down

0 comments on commit f20c782

Please sign in to comment.