Skip to content

Commit

Permalink
fix: keep the composed message when replying [WPB-982] 🍒 (#2970)
Browse files Browse the repository at this point in the history
Co-authored-by: Vitor Hugo Schwaab <[email protected]>
  • Loading branch information
github-actions[bot] and vitorhugods authored May 6, 2024
1 parent 92415e0 commit df97d3d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class MessageComposerStateHolder(
}

fun toReply(message: UIMessage.Regular) {
messageCompositionHolder.clearMessage()
messageCompositionHolder.setReply(message)
messageCompositionInputStateHolder.toComposing()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ class MessageComposerStateHolderTest {
runTest {
// given
// when
state.toReply(
message = mockMessageWithText
)
state.toReply(mockMessageWithText)

// then
assertEquals(
Expand All @@ -133,6 +131,22 @@ class MessageComposerStateHolderTest {
)
}

@Test
fun `given some message was being composed, when setting toReply, then input continues with the current text`() = runTest {
// given
val currentTextField = TextFieldValue("Potato")
messageCompositionHolder.setMessageText(currentTextField, {}, {}, {})

// when
state.toReply(mockMessageWithText)

// then
assertEquals(
currentTextField.text,
messageCompositionHolder.messageComposition.value.messageTextFieldValue.text
)
}

@Test
fun `given state, when input focus change to false, then clear focus`() = runTest {
// given
Expand Down

0 comments on commit df97d3d

Please sign in to comment.