Problem:
After building a page with a combination of magnolia-cms & angular, there appeared a problem. On the page, I had 2 link components(including <a href>
tags) on the bottom. So, when the page opened, it always auto-scrolled with a mini delay on the bottom. If I removed one of them, still it happened due to the other.
I tried to include window.scrollTo(0, 0);
(or document.respective_element.scrollTop()
) in both of the 2 components, but it did not work, unless I included a timeout of around 500ms or more. Which, of course, was not a proper or satisfying solution.
Workaround-solution:
Added an <a href>
tag in one of the top components(i.e. title), therefore, it auto-anchored there. So, no need for addition of window.scrollTo(0, 0);
or similar.
Needed-solution/explanation:
Why is this happening and how to prevent it? For example, one thing I tried is that attribute
autofocus="true"
caught the focus, but if autofocus="false"
, it just auto-scrolled down. Wouldn't it be better just this default situation not to exist? Just to prevent it somehow?