Closed Bug 1977204 Opened 4 months ago Closed 16 days ago

Clicking on the tab of a message will cause the message pane to lose focus

Categories

(Thunderbird :: Mail Window Front End, enhancement)

Thunderbird 140
enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: itagagaki, Assigned: arschmitz)

References

(Blocks 1 open bug)

Details

(Whiteboard: [consider-uplift])

Attachments

(2 files, 1 obsolete file)

Attached video issue.mp4

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36

Steps to reproduce:

  1. Open message in new tab
  2. Select message text (to keep track of the focus state of the message pane)
  3. Click on various places

Actual results:

Clicking on the subject row or tab of a message will cause that the message pane to lose focus.

The selection will turn gray, and you will not be able to scroll through the message using up/down keys.

Troubleshoot mode doesn't resolve the issue.

Expected results:

The focus should remain on the message pane unless you click outside of the window. If you click outside the window and then click on a message tab, the focus should return. And of course when you click on the subject row.

Summary: Clicking on the subject row or tab of a message will cause that the message pane to lose focus → Clicking on the tab title of a message will cause the message pane to lose focus

The loss of focus when clicking on the header / subject area of the message is expected as it is a click outside the window in an area with interactive content.

The tab title is a special case though where if that is clicked we really should not steal focus out, the same way firefox does not in this same case. This is not really so much of a bug though as an enhancment so im going to change it accordingly.

Type: defect → enhancement
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: WORKSFORME → ---
Severity: -- → S4
Status: REOPENED → NEW

I did some investigating.

Clicking on the subject row in the mail header pane causes the message pane to lose focus.
Here's why: Since the subject text is also selectable, attempting to select it shifts the focus to the header pane.
Similarly, we can also select the date text. However, clicking the left margin of the date does not shift the focus.
So why does clicking the right margin of the subject shift the focus instead of clicking the subject text itself?
It's because the subject box spans the full width of the pane; that area is not considered the margin.

https://searchfox.org/comm-central/rev/599abacfa0dd8643250857501fb98e3268fa3505/mail/themes/shared/mail/messageHeader.css#264-274

#expandedsubjectBox {
  font-weight: 700;
  flex: 1;
  margin-inline-start: calc(var(--message-header-field-offset) * -1);
  padding-inline: var(--message-header-field-offset);
  /* IMPORTANT! Keep these to avoid issues with very long subjects. Bug 77806 */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow-y: auto;
}

Removing flex: 1; resolved the issue. Is this necessary?

Further investigation is needed to resolve the issue of losing focus when clicking on a tab. This is a separate issue.

(In reply to itagagaki from comment #3)

So why does clicking the right margin of the subject shift the focus instead of clicking the subject text itself?

Should read:
So why does clicking the right margin of the subject instead of clicking the subject text itself shift the focus?

(In reply to itagagaki from comment #3)

Removing flex: 1; resolved the issue. Is this necessary?

Maybe the intention is to align the security info and the extra date label right.

https://searchfox.org/comm-central/rev/599abacfa0dd8643250857501fb98e3268fa3505/mail/base/content/msgHdrView.inc.xhtml#405-433

<!-- Subject + security info + extra date label for hidden To variation -->
<html:div id="headerSubjectSecurityContainer" class="message-header-row">
   <html:div id="expandedsubjectRow" class="header-row-grow">
    <label id="expandedsubjectLabel" class="message-header-label"
           value="&subjectField4.label;"/>
    <html:div id="expandedsubjectBox" is="simple-header-row"
              data-header-name="subject"></html:div>
  </html:div>
  <html:div id="cryptoBox" hidden="hidden">
    <html:button id="encryptionTechBtn"
                 class="toolbarbutton-1 crypto-button themeable-brighttext button-focusable"
                 data-l10n-id="message-security-button">
      <html:span class="crypto-label"></html:span>
      <html:img id="encryptedHdrIcon" hidden="hidden" alt="" />
      <html:img id="signedHdrIcon" hidden="hidden" alt="" />
    </html:button>
  </html:div>
  <html:time id="dateLabelSubject"
             class="message-header-datetime"
             aria-readonly="true"
             hidden="hidden"></html:time>
  <html:div id="darkReaderToggle" xmlns="http://www.w3.org/1999/xhtml">
    <label for="disableDarkReader" class="toggle-label">
      <input id="disableDarkReader"
             type="checkbox"
             class="toggle-checkbox toggle-checkbox-sm dark-reader-toggle" />
    </label>
  </html:div>
</html:div>

But after removing flex: 1 from #expandedsubjectBox, it still worked as intended.

See Also: → 1994194

The issue of clicking on the right margin of the subject in the header pane has been separated to Bug 1994194.
For this bug 1977204, let's narrow our focus to the scenario where a tab is clicked.

Summary: Clicking on the tab title of a message will cause the message pane to lose focus → Clicking on the tab of a message will cause the message pane to lose focus

Switching tabs calls MozTabmail.updateCurrentTab(), which also controls focus.
However, this does not occur when the currently active tab is clicked. I could not determine where focus is controlled in that case.
Using preventDefault() in the "mousedown" event on "tabmail-tab" prevented focus movement, but also disabled dragging.

Assignee: nobody → itagagaki
Status: NEW → ASSIGNED

I've pinpointed the problem area.

https://searchfox.org/comm-central/rev/3c4eb5af0272bb026a2cc1e4479b01c25ef10fb8/mozilla/toolkit/content/widgets/tabbox.js#450-462

on_mousedown(event) {
  if (event.button != 0 || this.disabled) {
    return;
  }

  this.container.ariaFocusedItem = null;

  if (this == this.container.selectedItem) {
    // This tab is already selected and we will fall
    // through to mousedown behavior which sets focus on the current tab,
    // Only a click on an already selected tab should focus the tab itself.
    return;
  }

This if-block shifts the focus from the tab panel to the tab itself.
Although the code appears to be intentional, its purpose is unclear.
Users are unlikely to welcome this.

Commenting this out resolved the issue.

      // if (this == this.container.selectedItem) {
      //   // This tab is already selected and we will fall
      //   // through to mousedown behavior which sets focus on the current tab,
      //   // Only a click on an already selected tab should focus the tab itself.
      //   return;
      // }

However, I hesitate to do so because I don't know the full extent of its impact.
Besides, this isn't the 'comm' part. I'm not sure if I should get involved.

Attachment #9520017 - Attachment is obsolete: true
Assignee: itagagaki → arschmitz
Whiteboard: [consider-uplift]

Pushed by jtracey@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/e8d3472f8f27
Ignore user focus on the current tab. r=tobyp,aleca,itagagaki

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

Attachment

General

Creator:
Created:
Updated:
Size: