Closed Bug 1719645 Opened 3 years ago Closed 3 years ago

Align calendar week view

Categories

(Calendar :: Calendar Frontend, enhancement)

Thunderbird 90
enhancement

Tracking

(thunderbird_esr78 unaffected)

RESOLVED FIXED
91 Branch
Tracking Status
thunderbird_esr78 --- unaffected

People

(Reporter: adrien.rybarczyk, Assigned: Paenglab)

Details

Attachments

(2 files, 2 obsolete files)

Attached image AlignmentFor78 β€”

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

Steps to reproduce:

Be in weekly view.

Actual results:

There is an offset pixel on the alignment.

Bug present in 78 and 90 but the offset is not the same.

Expected results:

The elements are aligned.

Status: RESOLVED → REOPENED
Component: General → Calendar Frontend
Ever confirmed: true
Product: Invalid Bugs → Calendar
Resolution: INVALID → ---
Version: unspecified → Thunderbird 90

This comes because the width of headerscrollbarspacer and labelscrollbarspacer are set 1px wider than the scrollbar width is. Tested on Linux and Windows.

Henry, do you know what could be wrong when the width is calculated here: https://searchfox.org/comm-central/rev/c821090d64c92a05bfc49aba6d5f0d25ad5ff52e/calendar/base/content/calendar-multiday-view.js#1934 ?

Flags: needinfo?(henry)

I found the issue: we set a margin here https://searchfox.org/comm-central/rev/c821090d64c92a05bfc49aba6d5f0d25ad5ff52e/calendar/base/themes/common/calendar-views.css#558.
Does a function exist that includes in the calculation the margins or do we need to add this margin manually?

(In reply to Richard Marti (:Paenglab) from comment #3)

Does a function exist that includes in the calculation the margins or do we need to add this margin manually?

getBoundingClientRect only returns the border area, you have to add the margin yourself.

This issue should get fixed as a side effect once I get round to Bug 1713130. If this isn't a huge priority to fix soon, you can add the dependency.

Flags: needinfo?(henry)

Is Bug 1713130 planned to land on TB 91? If not, I'll fix this here.

I've not got any specific release plan, so go ahead and fix this here

Attached patch 1719645-weekView-scrollbar-width.patch (obsolete) β€” β€” Splinter Review

Is this okay like this? I have only basic JS knowledge. So propose a smarter way if where is one.

Assignee: nobody → richard.marti
Status: REOPENED → ASSIGNED
Attachment #9230327 - Flags: review?(henry)
Comment on attachment 9230327 [details] [diff] [review]
1719645-weekView-scrollbar-width.patch

Review of attachment 9230327 [details] [diff] [review]:
-----------------------------------------------------------------

::: calendar/base/content/calendar-multiday-view.js
@@ +1950,5 @@
> +      // We need to include in our calculation the 1px margin-end of the
> +      // calendar-time-bar[orient="vertical"]
> +      if (this.getAttribute("orient") == "vertical") {
> +        scrollbarSize = scrollbar - 1;
> +      }

Since `scrollboxSize` and `scrollbar` are only used once, you can tidy up by dropping them and just using a non-const `scrollbarSize`.

To be on the safer side, instead of manually reducing by 1 pixel, when you compute the scrollboxChildrenSize above, you could use

let computedStyle = window.getComputedStyle(child);
if (this.getAttribute("orient") == "vertical") {
  scrollboxChildrenSize += parseFloat(computedStyle.marginLeft);
  scrollboxChildrenSize += parseFloat(computedStyle.marginRight);
} else {
  scrollboxChildrenSize += parseFloat(computedStyle.marginTop);
  scrollboxChildrenSize += parseFloat(computedStyle.marginBottom);
}

This way, if the margin changes to some other px value, this method won't break. Some disclaimers though, the parseFloat is needed because the computedStyle will return the string value, e.g. "1px", so it will ignore the trailing "px". This means that it will break if the margin is set to a non-px value, like "3em" or "auto", and in the latter case you'll have a NaN. So to be extra safe, you could check each computed value against the regular expression /^[0-9]+(\.[0-9]+\)?px$/ first.
Attached patch 1719645-weekView-scrollbar-width.patch (obsolete) β€” β€” Splinter Review

I think because we do the styling in our files we don't need to check with regex.

Attachment #9230327 - Attachment is obsolete: true
Attachment #9230327 - Flags: review?(henry)
Attachment #9230339 - Flags: review?(henry)
Comment on attachment 9230339 [details] [diff] [review]
1719645-weekView-scrollbar-width.patch

Review of attachment 9230339 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good. I've not reviewed via splinter before (only on phabricator). I just set the review to `+` to accept it. Not sure if that was right.
Attachment #9230339 - Flags: review?(henry) → review+

(In reply to Henry Wilkes [:henry] from comment #10)

I just set the review to + to accept it. Not sure if that was right.

Yes, that was right.

Target Milestone: --- → 91 Branch
Comment on attachment 9230339 [details] [diff] [review]
1719645-weekView-scrollbar-width.patch

Review of attachment 9230339 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good. I've not reviewed via splinter before (only on phabricator). I just set the review to `+` to accept it. Not sure if that was right.

::: calendar/base/content/calendar-multiday-view.js
@@ +1939,5 @@
>        // we subtract the size of the other scrollbox children from the size of the scrollbox
>        // to calculate the size of the scrollbar.
>        let scrollboxChildrenSize = 0;
>        for (const child of this.scrollbox.children) {
> +        let computedStyle = window.getComputedStyle(child);

Maybe add a comment to explain that we expect the margin to be set to a px value, so future people will be aware of the assumption.

Added a comment that we expect px.

Attachment #9230339 - Attachment is obsolete: true
Attachment #9230350 - Flags: review+

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/fc94169f2fda
In week view set the correct scrollbar width for the spacers. r=henry

Status: ASSIGNED → RESOLVED
Closed: 3 years ago3 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: