Closed Bug 2091995 Opened 10 days ago Closed 7 days ago

nytimes crossword scrolls off screen when typing (focus() on SVG element scrolls if its <svg> is partly off-screen)

Categories

(Core :: Layout: Scrolling and Overflow, defect)

Firefox 160
Unspecified
All
defect

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
relnote-firefox --- 162+
firefox-esr115 --- unaffected
firefox-esr153 --- wontfix
firefox160 --- wontfix
firefox161 --- wontfix
firefox162 --- fixed

People

(Reporter: bobmetarts, Assigned: tnikkel)

References

(Regression, )

Details

(Keywords: regression)

Attachments

(4 files, 1 external file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:159.0) Gecko/20100101 Firefox/159.0

Steps to reproduce

In the last week, while doing the New York Times crossword, whenever I try to fill in a square at the bottom of the puzzle (the last 4 or 5 rows), the whole screen jumps to the top and I have to scroll back down again to fill in the square. This is incredibly annoying. And it only happens in Firefox. Other browsers do not have this problem. This is obviously a bug in Version 159.

Actual results

Instead of letting me fill in the square, the whole screen jumped to the top.

Expected results

Nothing should have happened.

The Bugbug bot thinks this bug should belong to the 'Firefox for Android::General' component, but is not confident enough to move the bug to that component.

Component: Untriaged → General

The Bugbug bot is WRONG! This bug is on my Win 11 desktop version of Firefox, not on my android phone.

Thank you for reporting this, Bob!

I was able to reproduce the jumping behavior in Firefox 160 on Linux in the NYT Crossword puzzle, but not in Chrome.

Here is a minimal example:

<!doctype html>
<meta charset="utf-8">
<title>focus() on a visible SVG element scrolls when its &lt;svg&gt; is partly off screen</title>
<!--
Minimal test case (bug 2091995). The gold square, an SVG <g tabindex=0>, is fully visible; only the top 20px of its
<svg> are above the viewport. Calling focus() should not scroll.
Expected (Chrome 157): "ok". Actual (Firefox 160): the page jumps up.
-->
<p id="out" style="position:fixed;top:0;left:0;right:0;margin:0;padding:6px;background:#ffd;font:14px monospace">running…</p>
<div style="height:1000px"></div>
<svg width="200" height="400" style="display:block">
  <rect width="200" height="400" fill="#ddd"/>
  <g id="target" tabindex="0"><rect y="340" width="60" height="60" fill="gold"/></g>
</svg>
<div style="height:2000px"></div>
<script>
  history.scrollRestoration = "manual";
  onload = () => setTimeout(() => {
    const svg = document.querySelector("svg"), target = document.getElementById("target");
    scrollTo(0, svg.getBoundingClientRect().top + scrollY + 20);   // svg top edge 20px above the viewport
    const before = scrollY, top = target.getBoundingClientRect().top;
    target.focus();
    document.getElementById("out").textContent =
      `${Math.abs(scrollY - before) > 1 ? "BUG: page scrolled" : "ok: no scroll"} - scrollY ${Math.round(before)} -> ${Math.round(scrollY)}` +
      ` (target was at ${Math.round(top)}px of a ${innerHeight}px viewport) | ${navigator.userAgent}`;
  }, 0);
</script>

User agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:160.0) Gecko/20100101 Firefox/160.0

Component: General → Layout: Scrolling and Overflow
OS: Unspecified → All
Product: Firefox → Core
Version: Firefox 159 → Firefox 160
Summary: Jumping bug in Firefox version 159 → focus() on SVG element scrolls if its <svg> is partly off-screen
Attached file ex.html —

Testcase from comment 3.

See Also: → 1842679
Assignee: nobody → tnikkel
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: focus() on SVG element scrolls if its <svg> is partly off-screen → nytimes crossword scrolls off screen when typing (focus() on SVG element scrolls if its <svg> is partly off-screen)

Another testcase.

I was able to reproduce but I was also able to reproduce in a build from a year, so seems like it's been around for a while. I think bug 1842679 is what regressed this.

Keywords: regression
Regressed by: 1842679
See Also: 1842679 →

Set release status flags based on info from the regressing bug 1842679

SVG container frames like <g> don't set mRect, so scrolling one into view
(including focus()) used an empty rect at the origin of the outer <svg>. If
that point wasn't visible we would scroll even though the element itself was
fully visible. Use the same bounds getBoundingClientRect uses.

Pushed by tnikkel@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/1683369cd350 https://hg.mozilla.org/integration/autoland/rev/1fe0d05053de Use the SVG bounding box when scrolling an SVG element into view. r=layout-reviewers,emilio

I'm only the reporter of the bug and know nothing about how to fix the problem. But I just want to point out that in the last hour I can no longer access ANY of the New York Times games pages -- either in Firefox OR in Explorer. They are all marked: "This page no longer exists."
See the attached screenshot.

Status: NEW → RESOLVED
Closed: 7 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/65235 for changes under testing/web-platform/tests

Upstream PR merged by moz-wptsync-bot

:tnikkel did you want to nominate this for the Fx162 relnotes? If so, set the relnote-firefox flag to "?"

Possible wording:

Fixed the page jumping out of view while typing on some sites, such as the New York Times crossword.

Flags: needinfo?(tnikkel)

Release Note Request (optional, but appreciated)
[Why is this notable]: prominent site nytimes crossword
[Affects Firefox for Android]: theoretically, but nytimes crossword didn't hit this on android
[Suggested wording]: Fixed the page jumping out of view while typing on some sites, such as the New York Times crossword.
[Links (documentation, blog post, etc)]: none

relnote-firefox: --- → ?
Flags: needinfo?(tnikkel)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: