Skip to content

Commit a1b8448

Browse files
authored
#5838 Added checks for RichText() before initializing squire in Secure Reply message box (#5845)
* Added checks for RichText() before initializing squire * fix failing test * pr review: fix squire initialization * refactor * refactor
1 parent 8a45cb8 commit a1b8448

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

extension/chrome/elements/compose-modules/compose-input-module.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ export class ComposeInputModule extends ViewModule<ComposeView> {
3636
}
3737

3838
public setHandlers = () => {
39+
this.configureRichTextFormatting();
3940
this.view.S.cached('add_intro').on(
4041
'click',
4142
this.view.setHandler(el => this.actionAddIntroHandler(el), this.view.errModule.handle(`add intro`))
4243
);
43-
this.initSquire(this.isRichText());
4444
// Set lastDraftBody to current empty squire content ex: <div><br></div>)
4545
// https://github.com/FlowCrypt/flowcrypt-browser/issues/5184
4646
this.view.draftModule.setLastDraftBody(this.squire.getHTML());
@@ -54,7 +54,7 @@ export class ComposeInputModule extends ViewModule<ComposeView> {
5454
};
5555

5656
public removeRichTextFormatting = () => {
57-
if (this.view.inputModule.isRichText()) {
57+
if (this.isRichText()) {
5858
this.initSquire(false, true);
5959
}
6060
};
@@ -105,6 +105,14 @@ export class ComposeInputModule extends ViewModule<ComposeView> {
105105
return isInputLimitExceeded;
106106
};
107107

108+
private configureRichTextFormatting = () => {
109+
if (this.isRichText()) {
110+
this.addRichTextFormatting();
111+
} else {
112+
this.removeRichTextFormatting();
113+
}
114+
};
115+
108116
private initSquire = (addLinks: boolean, removeExistingLinks = false) => {
109117
const squireHtml = this.squire?.getHTML();
110118
const el = this.view.S.cached('input_text').get(0);

test/source/tests/compose.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,7 @@ export const defineComposeTests = (testVariant: TestVariant, testWithBrowser: Te
16861686
expect(await composePage.read('.swal2-html-container')).to.include('Send empty message?');
16871687
await composePage.waitAndClick('.swal2-cancel');
16881688
const footer = await composePage.read('@input-body');
1689-
expect(footer).to.eq('\n\n\n\n--\n\nflowcrypt.compatibility test footer with an img\n\nand second line\n');
1689+
expect(footer).to.eq('\n\n\n--\nflowcrypt.compatibility test footer with an img\nand second line');
16901690
await composePage.waitAndClick(`@action-send`);
16911691
expect(await composePage.read('.swal2-html-container')).to.include('Send empty message?');
16921692
await composePage.waitAndClick('.swal2-cancel');

0 commit comments

Comments
 (0)