Skip to content

Commit 116ae48

Browse files
author
Ioan Moldovan
authored
#5020 Fix: cc and bcc ui issue (#5932)
* fix: cc and bcc ui issue * fix: pr reviews
1 parent 6dd786d commit 116ae48

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export class ComposeRecipientsModule extends ViewModule<ComposeView> {
4444
private googleContactsSearchEnabled: boolean | Promise<boolean | undefined>;
4545

4646
private uniqueRecipientIndex = 0;
47+
private inputContainerPaddingBottom = '30px';
4748

4849
public constructor(view: ComposeView) {
4950
super(view);
@@ -91,13 +92,15 @@ export class ComposeRecipientsModule extends ViewModule<ComposeView> {
9192
this.view.S.now('cc').on(
9293
'click',
9394
this.view.setHandler(target => {
95+
$('#input-container-to').css('padding-bottom', 0);
9496
const newContainer = this.view.S.cached('input_addresses_container_outer').find(`#input-container-cc`);
9597
this.copyCcBccActionsClickHandler(target, newContainer);
9698
})
9799
);
98100
this.view.S.now('bcc').on(
99101
'click',
100102
this.view.setHandler(target => {
103+
$('#input-container-cc').css('padding-bottom', 0);
101104
const newContainer = this.view.S.cached('input_addresses_container_outer').find(`#input-container-bcc`);
102105
this.copyCcBccActionsClickHandler(target, newContainer);
103106
})
@@ -106,6 +109,7 @@ export class ComposeRecipientsModule extends ViewModule<ComposeView> {
106109
'click',
107110
this.view.setHandler(() => {
108111
this.view.S.cached('input_to').trigger('focus');
112+
this.setCorrectPaddingForInputContainer();
109113
})
110114
);
111115
this.view.S.cached('input_to').on(
@@ -405,6 +409,7 @@ export class ComposeRecipientsModule extends ViewModule<ComposeView> {
405409
this.showHideCcAndBccInputsIfNeeded();
406410
this.view.S.cached('input_addresses_container_outer').addClass('invisible');
407411
this.view.S.cached('recipients_placeholder').css('display', 'flex');
412+
$('.input-container').css('padding-bottom', '0');
408413
this.setEmailsPreview();
409414
this.hideContacts();
410415
this.view.sizeModule.setInputTextHeightManuallyIfNeeded();
@@ -914,6 +919,17 @@ export class ComposeRecipientsModule extends ViewModule<ComposeView> {
914919
sendingType: RecipientType,
915920
status: RecipientStatus
916921
): RecipientElement[] => {
922+
if (sendingType === 'to') {
923+
if ($('#input-container-cc').css('display') === 'none' && $('#input-container-bcc').css('display') === 'none') {
924+
container.parent().css('padding-bottom', this.inputContainerPaddingBottom);
925+
}
926+
}
927+
if (sendingType === 'cc') {
928+
if ($('#input-container-bcc').css('display') === 'none') {
929+
container.parent().css('padding-bottom', this.inputContainerPaddingBottom);
930+
}
931+
}
932+
917933
const result: RecipientElement[] = [];
918934
for (const { email, name, invalid } of emails) {
919935
const recipientId = this.generateRecipientId();
@@ -1156,12 +1172,17 @@ export class ComposeRecipientsModule extends ViewModule<ComposeView> {
11561172

11571173
private removeRecipient = (element: HTMLElement) => {
11581174
const index = this.addedRecipients.findIndex(r => r.element.isEqualNode(element));
1159-
this.addedRecipients[index].element.remove();
1175+
const recipient = this.addedRecipients[index];
1176+
// Adjust padding when the last recipient of a specific type is removed
1177+
if (this.addedRecipients.filter(r => r.sendingType === recipient.sendingType).length === 1) {
1178+
$(`#input-container-${recipient.sendingType}`).css('padding-bottom', '0');
1179+
}
1180+
recipient.element.remove();
11601181
const container = element.parentElement?.parentElement; // Get Container, e.g. '.input-container-cc'
11611182
if (container) {
11621183
this.view.sizeModule.resizeInput($(container).find('input'));
11631184
}
1164-
this.view.S.cached('input_addresses_container_outer').find(`#input-container-${this.addedRecipients[index].sendingType} input`).trigger('focus');
1185+
this.view.S.cached('input_addresses_container_outer').find(`#input-container-${recipient.sendingType} input`).trigger('focus');
11651186
this.addedRecipients.splice(index, 1);
11661187
this.view.pwdOrPubkeyContainerModule.showHideContainerAndColorSendBtn().catch(Catch.reportErr);
11671188
this.view.myPubkeyModule.reevaluateShouldAttachOrNot();
@@ -1253,6 +1274,14 @@ export class ComposeRecipientsModule extends ViewModule<ComposeView> {
12531274
}
12541275
};
12551276

1277+
private setCorrectPaddingForInputContainer = () => {
1278+
if (this.addedRecipients.some(r => r.sendingType === 'to') && !this.addedRecipients.some(r => r.sendingType === 'cc')) {
1279+
$('#input-container-to').css('padding-bottom', this.inputContainerPaddingBottom);
1280+
} else if (this.addedRecipients.some(r => r.sendingType === 'cc') && !this.addedRecipients.some(r => r.sendingType === 'bcc')) {
1281+
$('#input-container-cc').css('padding-bottom', this.inputContainerPaddingBottom);
1282+
}
1283+
};
1284+
12561285
private focusRecipients = () => {
12571286
this.view.S.cached('recipients_placeholder').hide();
12581287
this.view.S.cached('input_addresses_container_outer').removeClass('invisible');

0 commit comments

Comments
 (0)