Closed Bug 1679853 Opened 4 years ago Closed 4 years ago

remove <deck> from calendar-minimonth.js

Categories

(Calendar :: General, task)

Tracking

(thunderbird_esr78 wontfix, thunderbird84 wontfix)

RESOLVED FIXED
85 Branch
Tracking Status
thunderbird_esr78 --- wontfix
thunderbird84 --- wontfix

People

(Reporter: khushil324, Assigned: khushil324)

References

Details

Attachments

(1 file, 3 obsolete files)

Attachment #9190371 - Flags: review?(alessandro)
Status: NEW → ASSIGNED
Comment on attachment 9190371 [details] [diff] [review] Bug-1679853_de-deck-calendar-minimonth-js-0.patch Review of attachment 9190371 [details] [diff] [review]: ----------------------------------------------------------------- Looks good. I'm asking a quick ui-r to Richard to be sure that CSS edit is good to go.
Attachment #9190371 - Flags: ui-review?(richard.marti)
Attachment #9190371 - Flags: review?(alessandro)
Attachment #9190371 - Flags: review+

Comment on attachment 9190371 [details] [diff] [review]
Bug-1679853_de-deck-calendar-minimonth-js-0.patch

Not much CSS. It looks good, maybe a width: 9.5ch; would also work (on Windows it works.

A problem could be that locales use different label length. So localize the width could be better.

Attachment #9190371 - Flags: ui-review?(richard.marti) → ui-review+
Target Milestone: --- → 85 Branch

Alessandro, what about my comment 3 about the localized width?

Indeed, if we're setting a fixed width we should localize it so we avoid issues in other languages.
I see this section is using a properties file. Magnus, do you think it's worth moving those strings to fluent?

Flags: needinfo?(mkmelin+mozilla)

Since the mini-month widget has a fixed width, and the years have a fixed width, it should be possible to have the name too occupy a fixed width, without getting in trouble with localizations, at least any more than status quo.

Flags: needinfo?(mkmelin+mozilla)

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

Since the mini-month widget has a fixed width, and the years have a fixed width, it should be possible to have the name too occupy a fixed width, without getting in trouble with localizations, at least any more than status quo.

The minimonth has no fixed width. It adapts to the accumulated width of the items. The <deck> was to set the width of the widest element in it. When a locale had a wider month name the minimonth was wider than with en-US locale.

In that case, I'd further down in the connectedCallback(), once appended to the DOM, clone the day node and create boxes of visibility hidden for each of the days. Check which one has the largest width and set the box to use that.

Sure, I will update the patch accordingly.

I have tried to get the width of all the labels and but in the connectedCallback(), I am getting width as zero so used this:

let width = 0;
for (let i = 0; i < 12; i++) {
  let dateString = cal.l10n.getDateFmtString(`month.${i + 1}.name`);
  width = Math.max(dateString.length, width);
}
this.querySelector(".minimonth-month-name").style.width = width + "ch";
Attachment #9190371 - Attachment is obsolete: true
Attachment #9190990 - Flags: review?(alessandro)
Comment on attachment 9190990 [details] [diff] [review] Bug-1679853_de-deck-calendar-minimonth-js-1.patch Review of attachment 9190990 [details] [diff] [review]: ----------------------------------------------------------------- ::: calendar/base/content/widgets/calendar-minimonth.js @@ +142,5 @@ > > + let width = 0; > + for (let i = 0; i < 12; i++) { > + let dateString = cal.l10n.getDateFmtString(`month.${i + 1}.name`); > + width = Math.max(dateString.length, width); This won't work as you're not appending the string to the DOM. Let's follow Magnus' suggestion: - Generate all labels for all the month names. - Append them to the DOM and find the largest width. - Hide them all and toggle the visibility of the selected month.
Attachment #9190990 - Flags: review?(alessandro)

I didn't try, but since the unit is "ch" now, it might work. Could perhaps need padding as well, but essentially 1ch is one width of letter.

(In reply to Alessandro Castellani (:aleca) from comment #12)

Let's follow Magnus' suggestion:

  • Generate all labels for all the month names.
  • Append them to the DOM and find the largest width.
  • Hide them all and toggle the visibility of the selected month.

In the connectedCallback(), after appending the relevant labels, we are still not getting the width of the label i.e. we are getting width as zero for all the labels. So I find this as an available option. Else we need to do something in the onLoad function wherever we are using the calendar-minimonth, but it's not a safe option.

Flags: needinfo?(alessandro)
Comment on attachment 9190990 [details] [diff] [review] Bug-1679853_de-deck-calendar-minimonth-js-1.patch Review of attachment 9190990 [details] [diff] [review]: ----------------------------------------------------------------- Indeed, this works, not sure why the first time I tried it it wasn't working. Just a couple of tiny changes to do. ::: calendar/base/content/widgets/calendar-minimonth.js @@ +140,5 @@ > this.mValue = new Date(); // Default to "today". > this.mFocused = null; > > + let width = 0; > + for (let i = 0; i < 12; i++) { Here we can start the count from 1 and set the condition to i <= 12, so we can avoid doing an extra addition when getting the string. Add a comment to explain that the month strings start from 1. @@ +144,5 @@ > + for (let i = 0; i < 12; i++) { > + let dateString = cal.l10n.getDateFmtString(`month.${i + 1}.name`); > + width = Math.max(dateString.length, width); > + } > + this.querySelector(".minimonth-month-name").style.width = width + "ch"; nit: `${width}ch`
Attachment #9190990 - Flags: feedback+
Flags: needinfo?(alessandro)

I noticed that when cycling through September the area occupied by the name grows a bit and pushes other elements.
I think this is due to the padding Magnus pointed out before.
We could simply increase the width by 1 to account for that extra need space.

Attachment #9190990 - Attachment is obsolete: true
Attachment #9192048 - Flags: review?(geoff)
Attachment #9192048 - Flags: review?(alessandro)
Comment on attachment 9192048 [details] [diff] [review] Bug-1679853_de-deck-calendar-minimonth-js-2.patch Review of attachment 9192048 [details] [diff] [review]: ----------------------------------------------------------------- ::: calendar/base/content/widgets/calendar-minimonth.js @@ +140,5 @@ > this.mValue = new Date(); // Default to "today". > this.mFocused = null; > > + let width = 0; > + for (let i = 1; i <= 12; i++) { nit: Please add a comment here to explain why we're starting the loop from 1 instead of 0.
Attachment #9192048 - Flags: review?(alessandro) → review+
Comment on attachment 9192048 [details] [diff] [review] Bug-1679853_de-deck-calendar-minimonth-js-2.patch Review of attachment 9192048 [details] [diff] [review]: ----------------------------------------------------------------- I haven't tested this but the code changes look alright to me.
Attachment #9192048 - Flags: review?(geoff) → review+
Attachment #9192048 - Attachment is obsolete: true
Attachment #9192173 - Flags: review+

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/2f6b7de5097c
remove <deck> XUL element from calendar-minimonth.js. r=aleca,geoff

Status: ASSIGNED → RESOLVED
Closed: 4 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: