Compfields2Recipients leaves old entries intact
Categories
(Thunderbird :: Message Compose Window, defect)
Tracking
(Not tracked)
People
(Reporter: musiquegraeme, Assigned: darktrojan)
References
(Regression)
Details
(Keywords: regression)
Attachments
(1 file, 3 obsolete files)
|
8.56 KB,
patch
|
aleca
:
review+
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0
Steps to reproduce:
I tried to use Compfields2Recipients to expand the mailing list items in the to, cc and Bcc fields of the email.
Actual results:
All the addresses were added to what was already there.
Expected results:
They should have replaced the items that were there. This appears to be because CompFields2Recipients is different now between comm-release/mail/components/compose/content/addressingWidgetOverlay.js
and
comm-release/suite/mailnews/components/compose/content/addressingWidgetOverlay.js
Whereas it was the same in previous versions.
| Assignee | ||
Comment 1•5 years ago
|
||
Taking this because it's the same problem I need to solve for other reasons.
| Assignee | ||
Comment 2•5 years ago
|
||
Updated•5 years ago
|
Comment 3•5 years ago
•
|
||
| Assignee | ||
Comment 4•5 years ago
|
||
(In reply to Alessandro Castellani (:aleca) from comment #3)
Why this double condition?
If the first condition is not null it means that we have addresses to add.
There's no need for this.
That's not quite true. If msgCompFields.replyTo is an empty string (plausible, and wanted in my use case), msgReplyTo would be an empty array.
This shouldn't be here as the recipientAddPill method is called whenever a
new pill is created.
Adding this method here removes all the pills whenever a new is
typed/created/pasted, which makes the entire area unusable.
Also, calling this method for every added pill is very taxing.Since this issue is related to the CompFields2Recipients method not clearing
previous pills, we could add this at the beginning of that method:for (let pill of document.querySelectorAll("mail-address-pill")) {
pill.remove();
}
Yeah, that makes more sense.
| Assignee | ||
Comment 5•5 years ago
|
||
… although I'd want it on a per-field basis, since not specifying a value for a field should not change it.
Comment 6•5 years ago
|
||
(In reply to Geoff Lankow (:darktrojan) from comment #4)
That's not quite true. If
msgCompFields.replyTois an empty string (plausible, and wanted in my use case),msgReplyTowould be an empty array.
In that case, what's the point of triggering the recipientAddPill() method if the array is empty?
Since we won't actually generate any pill, we update the first condition as:
if (msgReplyTo && msgReplyTo.lenght) {
What do you think?
… although I'd want it on a per-field basis, since not specifying a value for a field should not change it.
Then maybe creating an helper function like clearRecipientPills(input) to call for each recipient type might be a good solution.
That function can then do something like you did originally:
for (let pill of input.closest(".address-container").getElementsByTagName("mail-address-pill")) {
pill.remove();
}
| Assignee | ||
Comment 7•5 years ago
|
||
That's basically what I had in mind. I've called the function recipientClearPills to match recipientAddPill (which is a bit of a misnomer IMO, never mind). If you can think of a better wording for the comment, be my guest.
| Assignee | ||
Comment 8•5 years ago
|
||
Here's a tidier way of doing CompFields2Recipients. It seems that the only reason it was in two parts (all the variables worked out first, then the if blocks) was for the call to addRecipientsToIgnoreList at the bottom, but the variables aren't needed for that because recipientAddPill also calls addRecipientsToIgnoreList.
I didn't combine this with the first patch because you may disagree that it is better, and also reading the changes in two parts should be easier.
Comment 9•5 years ago
|
||
Comment 10•5 years ago
|
||
| Assignee | ||
Comment 11•5 years ago
|
||
If we passed a value, then yes we want to clear the pills. There has to be a way to say we don't want any addresses in a field, and this is it.
| Assignee | ||
Comment 12•5 years ago
|
||
This differs only in the documentation and the test for a value. With this, some code can do
CompFields2Recipients({
to: "foo@invalid",
cc: "",
bcc: null,
});
which will set To, clear CC and completely ignore BCC (also Reply To and the others not specified). Since in my WebExtensions use-case any property not specified is set to null, it prevents a bit of marshalling beforehand.
Comment 13•5 years ago
|
||
Comment 14•5 years ago
|
||
Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/26bc58b44952
Remove old addressing entries when Compfields2Recipients is called. r=aleca
| Assignee | ||
Updated•5 years ago
|
Updated•5 years ago
|
Description
•