@@ -40,6 +40,7 @@ export class GmailElementReplacer extends WebmailElementReplacer {
40
40
private removeNextReplyBoxBorders = false ;
41
41
private lastSwitchToEncryptedReply = false ;
42
42
private replyOption : ReplyOption | undefined ;
43
+ private lastReplyOption : ReplyOption | undefined ;
43
44
44
45
private sel = {
45
46
// gmail_variant=standard|new
@@ -642,6 +643,8 @@ export class GmailElementReplacer extends WebmailElementReplacer {
642
643
const legacyDraftReplyRegex = new RegExp ( / \[ ( f l o w c r y p t | c r y p t u p ) : l i n k : d r a f t _ r e p l y : ( [ 0 - 9 a - f r \- ] + ) ] / ) ;
643
644
const newReplyBoxes = $ ( 'div.nr.tMHS5d, td.amr > div.nr, div.gA td.I5' ) . not ( '.reply_message_evaluated' ) . filter ( ':visible' ) . get ( ) ;
644
645
if ( newReplyBoxes . length ) {
646
+ // removing this line will cause unexpected draft creation bug reappear
647
+ // https://github.com/FlowCrypt/flowcrypt-browser/issues/5616#issuecomment-1972897692
645
648
this . replyOption = undefined ;
646
649
// cache for subseqent loop runs
647
650
const convoRootEl = this . getConvoRootEl ( newReplyBoxes [ 0 ] ) ;
@@ -688,6 +691,10 @@ export class GmailElementReplacer extends WebmailElementReplacer {
688
691
const replyOption = this . parseReplyOption ( replyBox ) ;
689
692
if ( replyOption ) {
690
693
this . replyOption = replyOption ;
694
+ this . lastReplyOption = replyOption ;
695
+ } else if ( this . lastReplyOption ) {
696
+ this . replyOption = this . lastReplyOption ;
697
+ this . lastReplyOption = undefined ;
691
698
}
692
699
replyParams . replyOption = this . replyOption ;
693
700
// either is a draft in the middle, or the convo already had (last) box replaced: should also be useless draft
@@ -708,8 +715,10 @@ export class GmailElementReplacer extends WebmailElementReplacer {
708
715
if ( hasDraft || alreadyHasSecureReplyBox ) {
709
716
replyBox . addClass ( 'reply_message_evaluated remove_borders' ) . parent ( ) . append ( secureReplyBoxXssSafe ) ; // xss-safe-factory
710
717
replyBox . hide ( ) ;
718
+ this . lastReplyOption = undefined ;
711
719
} else if ( isReplyButtonView ) {
712
720
replyBox . replaceWith ( secureReplyBoxXssSafe ) ; // xss-safe-factory
721
+ this . lastReplyOption = undefined ;
713
722
this . replyOption = undefined ;
714
723
} else {
715
724
const deleteReplyEl = document . querySelector ( '.oh.J-Z-I.J-J5-Ji.T-I-ax7' ) ;
0 commit comments