File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -1287,7 +1287,14 @@ describe(`EditMessageForm`, () => {
12871287 customChannel,
12881288 customClient,
12891289 } ) ;
1290- await quotedMessagePreviewIsDisplayedCorrectly ( mainListMessage ) ;
1290+ await quotedMessagePreviewIsDisplayedCorrectly (
1291+ messageWithQuotedMessage . quoted_message ,
1292+ ) ;
1293+ await waitFor ( ( ) => {
1294+ const textarea = screen . getByPlaceholderText ( inputPlaceholder ) ;
1295+ expect ( textarea ) . toBeInTheDocument ( ) ;
1296+ expect ( textarea . value ) . toBe ( messageWithQuotedMessage . text ) ;
1297+ } ) ;
12911298 } ) ;
12921299
12931300 it ( 'renders proper markdown (through default renderText fn)' , async ( ) => {
@@ -1356,7 +1363,14 @@ describe(`EditMessageForm`, () => {
13561363 customChannel ,
13571364 ) ;
13581365 } ) ;
1359- await quotedMessagePreviewIsDisplayedCorrectly ( mainListMessage ) ;
1366+ await quotedMessagePreviewIsDisplayedCorrectly (
1367+ messageWithQuotedMessage . quoted_message ,
1368+ ) ;
1369+ await waitFor ( ( ) => {
1370+ const textarea = screen . getByPlaceholderText ( inputPlaceholder ) ;
1371+ expect ( textarea ) . toBeInTheDocument ( ) ;
1372+ expect ( textarea . value ) . toBe ( messageWithQuotedMessage . text ) ;
1373+ } ) ;
13601374 } ) ;
13611375
13621376 it ( 'is closed on original message delete' , async ( ) => {
Original file line number Diff line number Diff line change @@ -235,6 +235,19 @@ export const TextareaComposer = ({
235235 }
236236 } , [ textComposer . suggestions ] ) ;
237237
238+ useEffect ( ( ) => {
239+ /**
240+ * The textarea value has to be overridden outside the render cycle so that the events like compositionend can be triggered.
241+ * If we have overridden the value during the component rendering, the compositionend event would not be triggered, and
242+ * it would not be possible to type composed characters (ô).
243+ * On the other hand, just removing the value override via prop (value={text}) would not allow us to change the text based on
244+ * middleware results (e.g. replace characters with emojis)
245+ */
246+ const textarea = textareaRef . current ;
247+ if ( ! textarea ) return ;
248+ textarea . value = text ;
249+ } , [ textareaRef , text ] ) ;
250+
238251 return (
239252 < div
240253 className = { clsx (
@@ -271,7 +284,6 @@ export const TextareaComposer = ({
271284 ref = { ( ref ) => {
272285 textareaRef . current = ref ;
273286 } }
274- value = { text }
275287 />
276288 { /* todo: X document the layout change for the accessibility purpose (tabIndex) */ }
277289 { ! isComposing && (
You can’t perform that action at this time.
0 commit comments