Closed Bug 1663427 Opened 4 years ago Closed 3 years ago

Error when opening PDF attachment from message displayed in a window with "Open messages in: A new message window": document.getElementById("tabmail") is null

Categories

(Thunderbird :: General, defect)

Thunderbird 82
defect

Tracking

(thunderbird_esr78 unaffected)

RESOLVED FIXED
88 Branch
Tracking Status
thunderbird_esr78 --- unaffected

People

(Reporter: foss, Assigned: henry-x)

References

Details

(Keywords: regression)

Attachments

(1 file)

Hello,

One of my colleague today who is not able to open attachments on TB Daily contacted me.

Steps to reproduce:

  1. Open a mail with at least one PDF in attachment
  2. Try to right click on the PDF and click on open

Result:
Nothing is happening.

Expected result:
The PDF open prompt should be opened.

Important note:
After a bit of investigation I found it is specific to PDF and because now the default preference for PDF files is "previous in Thunderbird" (translated from French). My colleague and I don't made any change into ours Thunderbird profiles.

Best regards.

On Daily, PDFs open in a new Thunderbird tab (we integrated pdf.js).

(In reply to Magnus Melin [:mkmelin] from comment #1)

On Daily, PDFs open in a new Thunderbird tab (we integrated pdf.js).

OK, thanks for the clarification. With this in mind I made a new test, it works indeed in I change my pref to "open new message in new tab" but not with the preference "open new message in new window".

If I change the preference to "Open messages in: An existing message window" a PDF attachment will open in a new tab when I left-click the filename, right-click on the filename and select "Open", or left-click and select "Open" from the drop-down with "Save" and other choices.

The same if the preference is "A new tab" or "A new window". Probably because it is not a message, but is an attachment.

If there are multiple attachments and I display them using the > arrow, they open in a new tab when I left double-click on the attachment, or right-click and select "Open".

Mozilla/5.0 (X11; Linux x86_64; rv:82.0) Gecko/20100101 Thunderbird/82.0a1 Build ID: 20200906103246

What operating system are you using Alex?

Flags: needinfo?(aarnaud)

(In reply to WaltS48 [:walts48] from comment #3)

What operating system are you using Alex?

I'm on Debian GNU/Linux version 10.

Flags: needinfo?(aarnaud)
Component: Untriaged → General
Keywords: regression

My observations before and after the change introduced by "pdf.js"
Before
If I "Open" a pdf attachment to a message either previewed in a tab, or displayed in a new window, then the attachment is displayed by whatever pdf viewer was selected in "preferences".
After
Change the "preferences " back to "preview in Thunderbird",
If I "Open" a pdf attachment in a message previewed in a tab, the pdf is displayed in a new tab in the Thunderbird window. In this situation "pdf.js" has an environment in which it run successfully
If I "Open" a pdf attachment in a message displayed in a new window, nothing happens. I presume in this situation "pdf.js" does not have the correct environment required to run.

My first instinct is to suggest that messages be either previewed or displayed in tabs, write message included, but that is a fundamental change I believe.
The other solution,perhaps, is to have two preferences, one for "message in tab" and one for "message in window".

But from what I can see currently, it is not possible to set "preferences" to "Preview in Thunderbird" and display pdf attachments in either tabbed or windowed messages. That looks like a bug as it means you have to switch windows (back to the preview tab) in order to display a pdf.

No sarcasm intended, but is this just a new feature? In which case the restriction should be documented.

A separate comment.
Bug report always end up sounding critical of the developer, my apologies.
The "pdf.js" feature is an excellent addition - well done to all concerned.

(In reply to Alex ARNAUD from comment #0)

Steps to reproduce:

  1. Open a mail with at least one PDF in attachment
  2. Try to right click on the PDF and click on open

Hi Alex ARNAUD, two important infos missing from your steps:

  • set preference Open messages in: A new message window
  • try to open PDF attachment from message displayed in a standalone window

Result:
Nothing is happening.

Confirmed. Console error (see below).

Important note:
After a bit of investigation I found it is specific to PDF and because now the default preference for PDF files is "previous in Thunderbird" (translated from French).

"Preview in Thunderbird" is the new default yes. As a workaround for this bug, you could change that to another default action.

(In reply to clochrua from comment #5)
Thanks clochrua. You are mostly right. Try to use some markdown formatting and blank lines in your comments to make them more readable.

If I "Open" a pdf attachment in a message displayed in a new window, nothing happens. I presume in this situation "pdf.js" does not have the correct environment required to run.

Correct. Console error:

Uncaught (in promise) TypeError: can't access property "openTab", document.getElementById(...) is null
    open chrome://messenger/content/msgHdrView.js:2062
    actionFunction chrome://messenger/content/msgHdrView.js:3337
    HandleMultipleAttachments chrome://messenger/content/msgHdrView.js:3347
    HandleSelectedAttachments chrome://messenger/content/msgHdrView.js:3245
    attachmentItemCommand chrome://messenger/content/msgHdrView.js:2453
    insertItemAt chrome://messenger/content/mailWidgets.js:1566
msgHdrView.js:2062:20
      document.getElementById("tabmail").openTab("contentTab", {
        contentPage: this.url,
        background: false,
      });

My first instinct is to suggest that messages be either previewed or displayed in tabs, write message included, but that is a fundamental change I believe.

We're not yet there (compose-in-a-tab, bug 449299), and it wouldn't help for this bug.

The other solution,perhaps, is to have two preferences, one for "message in tab" and one for "message in window".

Nah, 2 prefs is too much, but we can try a separate intelligent default. I'll ask Alex ARNAUD in a separate comment what is best from his POV.

But from what I can see currently, it is not possible to set "preferences" to "Preview in Thunderbird" and display pdf attachments in either tabbed or windowed messages. That looks like a bug as it means you have to switch windows (back to the preview tab) in order to display a pdf.

It's a bug for users of that preference, now confirmed :-)

Summary: No longer able to open PDF in attachments → Error when opening PDF attachment from message displayed in a window with "Open messages in: A new message window": document.getElementById("tabmail") is null

Alex ARNAUD (as representative of the blind), what do you think about the following proposal?
And Alex (:aleca)?

Proposed fix:

  • For users who are deliberately not using tabs, but want/need to see every message in a separate window using the pref (which probably improves access e.g. for the blind), we probably wouldn't help them much by stubbornly opening the pdf in a tab in 3-pane or even another tab in the standalone message window (which might be non-trivial).
  • I suggest that for users with the pref set to anything other than tabs (Open messages in: A new message window or ... An existing message window), we should have a conditional which redirects the PDF viewing into a new window instead of a tab when "Preview in Thunderbird" is used.
  • So tab-centric users get PDF in a tab, and window-centric users get it in a window. Everyone happy, no extra prefs needed. Open a new Thunderbird browser window and load the PDF - doesn't sound very hard either wrt implementation.
Flags: needinfo?(alessandro)
Flags: needinfo?(aarnaud)

(In reply to Thomas D. (:thomas8) from comment #8)

Proposed fix:

  • So tab-centric users get PDF in a tab, and window-centric users get it in a window. Everyone happy, no extra prefs needed. Open a new Thunderbird browser window and load the PDF - doesn't sound very hard either wrt implementation.

If it turns out that loading the PDF into a new Thunderbird window is too difficult for us, Magnus suggested the following variant of fixing this:

  • If user has "open in new/existing window" pref active, and opens PDF attachment from standalone window:
  • Thunderbird should then try to open the attachment with the user's external PDF viewer.
  • Iow, that would need a conditional which ignores the "open-inline" flavor and uses the "open-external" flavor instead.

I agree with the approach proposed on comment 9.

Flags: needinfo?(alessandro)

(In reply to Thomas D. (:thomas8) from comment #9)

(In reply to Thomas D. (:thomas8) from comment #8)

Proposed fix:

  • So tab-centric users get PDF in a tab, and window-centric users get it in a window. Everyone happy, no extra prefs needed. Open a new Thunderbird browser window and load the PDF - doesn't sound very hard either wrt implementation.

If it turns out that loading the PDF into a new Thunderbird window is too difficult for us, Magnus suggested the following variant of fixing this:

  • If user has "open in new/existing window" pref active, and opens PDF attachment from standalone window:
  • Thunderbird should then try to open the attachment with the user's external PDF viewer.
  • Iow, that would need a conditional which ignores the "open-inline" flavor and uses the "open-external" flavor instead.

LGTM, too. Using the external PDF viewer has never been a difficulty for the users we help.

Flags: needinfo?(aarnaud)

The code is around here: https://searchfox.org/comm-central/rev/7dcededfeafb2a0c052c7329cc7cfdcbc7f1111c/mail/base/content/msgHdrView.js#2044-2067

I think, we could do it like this: if tabmail is not found, try to find a 3pane Services.wm.getMostRecentWindow("mail:3pane");. If none is open, just open it as other attachments.

Assignee: nobody → henry
Blocks: 810815
Status: NEW → ASSIGNED
Target Milestone: --- → 88 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/de2b7a0360ec
Handle missing tabmail when opening pdfs internally. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: