window.scrollTo with smooth behavior is no longer working
Categories
(Core :: Panning and Zooming, defect)
Tracking
()
People
(Reporter: philippemp11, Unassigned)
Details
Attachments
(1 file)
|
1.77 KB,
text/html
|
Details |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0
Steps to reproduce:
I'm calling the function below with smooth = true
ABCD.scroll_to_element = function(elem, voffset, hoffset, smooth){
const etop = elem.getBoundingClientRect().top;
const btop = document.body.getBoundingClientRect().top;
const eleft = elem.getBoundingClientRect().left;
const bleft = document.body.getBoundingClientRect().left;
window.scrollTo({
top: etop - (btop + voffset),
left: eleft - (bleft + hoffset),
behavior: smooth ? 'smooth' : 'instant'
});
}
Actual results:
Nothing, it is not scrolling to the element in param
Expected results:
It should have scrolled to the element in param
User Agent String:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0
Note:
- everything is working well with behavior: 'instant'
- to be more accurate, it is sometimes working with behavior: 'smooth' and sometimes not. From what I observed so far, it depends on where the <a href="..."> tag calling the function is located:
- if the <a> tag is located in a <div > (display:inline-block) directly in the HTML page body, it is working well
- if the <a> tag is located in nested blocks with a <div> (position:fixed) at the root level, it is not working properly
- I tested with Edge and Chrome and everything is working well
I do not have exact reproduction steps so far. I'm happy to help on more in details reproduction steps, please let me know
Updated•3 years ago
|
Comment 1•3 years ago
|
||
If you can upload an html file that reproduces for you that would be helpful.
| Reporter | ||
Comment 2•3 years ago
|
||
| Reporter | ||
Comment 3•3 years ago
|
||
I finally managed to identify the root cause
If I get document.body.style.overflowY = 'auto', it’s working well, but if I get document.body.style.overflowY = 'hidden' it is not scrolling to the element
Please find the HTML file in attachment
Comment 4•3 years ago
|
||
Thanks for the testcase. Sounds like you may be running into bug 1519339.
| Reporter | ||
Comment 5•3 years ago
|
||
Yes this is the same issue, thank you
Comment 6•3 years ago
|
||
Thanks, will close as duplicate. That bug has been around for a long time but this is a good reminder to put it on the roadmap for fixing.
If you have examples of production websites that you know to be affected, please feel free to mention them, that helps make the case for fixing it sooner.
Description
•