Closed Bug 1956624 Opened 9 months ago Closed 9 months ago

Expand on hover not working as expected if window is not foregrounded

Categories

(Firefox :: Sidebar, defect, P2)

Desktop
macOS
defect

Tracking

()

VERIFIED FIXED
139 Branch
Tracking Status
firefox138 --- verified
firefox139 --- verified

People

(Reporter: kcochrane, Assigned: kcochrane)

References

(Blocks 1 open bug, Regressed 1 open bug)

Details

(Whiteboard: [fidefe-sidebar])

Attachments

(1 file)

As part of bug 1950419, we switched from using mouseenter/mouseleave on the sidebar itself to using MousePosTracker in browser.js. This has introduced an issue where the sidebar will expand on hover if the window is not foregrounded but will only collapse back down if you foreground the window or hover over the browser chrome area. We should investigate this in order to ensure this works as expected even when the window is not foregrounded.

Blocks: 1930188
Severity: -- → S4
Priority: -- → P2

This seems to only be affecting MacOS for some reason

Assignee: nobody → kcochrane
Status: NEW → ASSIGNED
OS: Unspecified → macOS
Hardware: Unspecified → Desktop

This appears to be due to changes made here. Switching the component to Core:Widget: Cocoa per Smaug's recommendation. We should still listen for mousemove events on macOS even if the window isn't foregrounded if possible.

Component: Sidebar → Widget: Cocoa
Product: Firefox → Core
Assignee: kcochrane → nobody
Status: ASSIGNED → NEW

The behavior should be probably a bit different where at least mousemoves get through to the browser window, but if target is inside a <browser>, target should be <browser> itself and possible cross-process event forwarding shouldn't happen.
But the behavior is so Mac specific, that I might miss something here.

Flags: needinfo?(mstange.moz)

(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #3)

The behavior should be probably a bit different where at least mousemoves get through to the browser window, but if target is inside a <browser>, target should be <browser> itself and possible cross-process event forwarding shouldn't happen.

That sounds reasonable.

But I think I have a JS solution that we can use in this bug: When the mouse moves from the sidebar to the browser in the inactive window, widget will send a mouseout event. The mouseout event is going to have a position that will be outside the sidebar rectangle. The reason why the sidebar's MousePosTracker listener isn't notified is that MousePosTracker is only looking at mousemove events. But if it looked at the coordinates of mouseout events too, not just of mousemove events, then it would detect this outside-of-sidebar-rectangle position and notify the sidebar's listener.

So I suggest making MousePosTracker handle window mouseout events in addition to mousemove events.

Flags: needinfo?(mstange.moz)

Moving this back to Firefox::Sidebar component given the above suggestion. This change seems to work well in most cases although when mousing out of the window, we can intermittently see an x position for the event that's still within the bounds of the sidebar element for some reason even if you've moused out of the window entirely. Hoping to file something to address that at the widget level.

Component: Widget: Cocoa → Sidebar
Product: Core → Firefox
Assignee: nobody → kcochrane
Status: NEW → ASSIGNED
See Also: → 1957114

Filed bug 1957114 as a follow-up to investigate the issue mentioned above ^

Pushed by kcochrane@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/360a512b400f Ensure sidebar collapses on mouse out when expand on hover is enabled and the window is inactive (macOS only) r=sidebar-reviewers,mstange,sclements

Comment on attachment 9475456 [details]
Bug 1956624 - Ensure sidebar collapses on mouse out when expand on hover is enabled and the window is inactive (macOS only)

Beta/Release Uplift Approval Request

  • User impact if declined/Reason for urgency: Mac users will find the sidebar expand on hover feature only works as expected if the browser window is foregrounded
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: On a mac, enable the new sidebar and expand on hover. Foreground a different window from the browser and ensure expand on hover still works as expected. Please also note that bug 1957024 is a separate issue.
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Small JS change
  • String changes made/needed:
  • Is Android affected?: No
Attachment #9475456 - Flags: approval-mozilla-beta?
Flags: qe-verify+
Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 139 Branch
QA Whiteboard: [qa-triaged]

Hey Kelly, I was able to reproduce the sidebar staying open while the main window is out of focus. While verifying on Firefox 139.0a1 (2025-04-03 & the latest treeherder build) which has the patch, I was still able to reproduce this. Here's an attachment with the behavior I am getting. Any clue why this may be still happening?

Flags: needinfo?(kcochrane)

(In reply to Catalin Sasca, Desktop Test Engineering [:csasca] from comment #11)

Here's an attachment with the behavior I am getting. Any clue why this may be still happening?

I believe the video shows the bug happening in the conditions that are explained by bug 1957114, i.e. when leaving the sidebar via the window edge.

Ooh, that's how I recorded the first video, leaving via the window edge. But this is happening even with the mouse over the Fx window (leaving the sidebar on the right side), here's an attachment with it.

(In reply to Catalin Sasca, Desktop Test Engineering [:csasca] from comment #13)

Ooh, that's how I recorded the first video, leaving via the window edge. But this is happening even with the mouse over the Fx window (leaving the sidebar on the right side), here's an attachment with it.

Mousing out quickly towards the content area is due to bug 1957114. I think this is still a huge improvement from where it was because non-foregrounded windows were running into this a lot more frequently without this change. The browser essentially stops listening for mousemove events on macOS if the window isn't foregrounded, so we've added a mouseout event as well that should fire when you mouse out of the sidebar, but we're getting unexpected x position values for the mouseout event if the mouse out happens very quickly.

Flags: needinfo?(kcochrane)

I see. The fix indeed makes the sidebar more consistent now while not on focus on Firefox 139.0a1 (2025-04-03) than on the older affected builds. Thanks for the explanations! Will look over the fix when it will arrive on 138 as well.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-triaged]
Flags: qe-verify+

Comment on attachment 9475456 [details]
Bug 1956624 - Ensure sidebar collapses on mouse out when expand on hover is enabled and the window is inactive (macOS only)

Approved for 138.0b4

Attachment #9475456 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Verified the fix on Firefox 138.0b4 (treeherder build) as well on macOS 15.4 and everything looks good.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: