Closed Bug 1725160 Opened 3 years ago Closed 3 years ago

Recommended by pocket card context menu is cut off if opened on the right side

Categories

(Firefox :: Pocket, defect)

Desktop
All
defect

Tracking

()

VERIFIED FIXED
93 Branch
Tracking Status
firefox-esr78 --- unaffected
firefox-esr91 --- unaffected
firefox91 --- unaffected
firefox92 --- verified
firefox93 --- verified

People

(Reporter: atrif, Assigned: thecount)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

Affected versions

  • 92.0b2 (20210810185524)
  • 93.0a1 (20210810213316)

Affected platforms

  • macOS 10.13
  • Windows 10x64

Preconditions

  • browser.search.region:US

Steps to reproduce

  1. Open Firefox and a new tab.
  2. Click on the Open Menu from the right side pocket card.

Expected result

  • Menu is displayed as expected on the left side.

Actual result

  • Menu is cut off and opened on the right side.

Regression range

Notes

  • Attached a screenshot.
Has Regression Range: --- → yes
Has STR: --- → yes
Component: New Tab Page → Pocket
Flags: needinfo?(zbraniecki)

I suspect the sizing of the popup is not waiting for the UI to be localized and the recent change to l10n microtask exposed this bug.

The way to fix this is to improve the code to wait for DOM Fragment to be localized before sizing it.

Flags: needinfo?(zbraniecki)

:zbraniecki do you have thoughts on how to move this bug forward.

Flags: needinfo?(zbraniecki)

no, I do not know the code in question.

Flags: needinfo?(zbraniecki)
Assignee: nobody → sdowne

I can take a look today.

The code in question is here.

https://searchfox.org/mozilla-central/source/browser/components/newtab/content-src/components/DiscoveryStreamComponents/DSLinkMenu/DSLinkMenu.jsx#32-36

I think I just need to know when the DOM Fragment is localized. Is there an event or some way to determine that?

Flags: needinfo?(zbraniecki)

I think I just need to know when the DOM Fragment is localized. Is there an event or some way to determine that?

Can you show where the l10n is applied?

I agree that rAF is a perfect way to introduce intermittent bug, so I'm glad we're moving away from it. What it should be replaced with depends on how the l10n binding is constructed.

Flags: needinfo?(zbraniecki) → needinfo?(sdowne)

If I understand you, the l10n binding is happening with data-l10n-id, these menu items get that set here: https://searchfox.org/mozilla-central/source/browser/components/newtab/content-src/components/ContextMenu/ContextMenu.jsx#170

Unfortunately, there is a significant amount of abstraction from the Pocket panel calling rAF to the actual setting of data-l10n-id, that I might need to work around.

Hopefully that helps answer the question.

Flags: needinfo?(sdowne) → needinfo?(zbraniecki)

Ok, that's quite imperfect because what you really would want to do is:

let fragment = document.createDocumentFragment(```
  <div data-l10n-id="key1"/>
```);

await document.l10n.translateFragment(fragment);
root.appendChild(fragment);

this would guarantee that when you inject the fragment it is localized.

In the absence of that, you can just force-translate which will in the worst case re-translate a fragment:

await document.l10n.translateFragment(myFragment);
readTheSizing();
Flags: needinfo?(zbraniecki)

I'll see hat I can do with that tomorrow.

If that doesn't work well, we could also use a mutation observer on the element and resized once the mutation observer fires with a non 0 width?

A hack, but seems pretty straight forward.

In theory one the localization is done it should update the contents of the element, and trigger the mutation observer.

Flags: needinfo?(zbraniecki)

I can't see a reason that forced translation might not work, but a mutation observer would be an acceptable fallback if I'm wrong.

Flags: needinfo?(zbraniecki)

I think I've got a patch for this, with a test to cover this in the future. I put you down as an optional review, feel free to take a look if you want.

The solution to force-translate to re-translate a fragment actually worked pretty well, so went with that.

Flags: needinfo?(zbraniecki)
Flags: needinfo?(zbraniecki)

Comment on attachment 9237104 [details]
Bug 1725160 - Fixing newtab Pocket context menu position.

Beta/Release Uplift Approval Request

  • User impact if declined: User experience

  • Is this code covered by automated tests?: Yes

  • Has the fix been verified in Nightly?: No

  • Needs manual test from QE?: Yes

  • If yes, steps to reproduce: Steps to reproduce

    Open Firefox and a new tab.
    Click on the Open Menu from the right side pocket card.

Expected result

Menu is displayed as expected on the left side.

Actual result

Menu is cut off and opened on the right side.
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): It's a pretty small js change.
  • String changes made/needed: none
Attachment #9237104 - Flags: approval-mozilla-beta?
Flags: qe-verify+
Pushed by sdowne@getpocket.com:
https://hg.mozilla.org/integration/autoland/rev/26433f71bd48
Fixing newtab Pocket context menu position. r=gvn,zbraniecki
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 93 Branch

Comment on attachment 9237104 [details]
Bug 1725160 - Fixing newtab Pocket context menu position.

Thanks for getting this fixed in time. Approved for 92.0b9.

Flags: needinfo?(sdowne)
Attachment #9237104 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [qa-triaged]

Verified fixed with 93.0a1 (20210829215733) and 92.0b9 (20210826192006) on Windows 10x64, macOS 10.15 and Ubuntu 21.04. The Pocket context menu is opened as expected if triggered from the right side.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: