Closed ASNNetworks closed 9 months ago
Bump
Please do not bump unless the stale bot asks you to.
Yep same issue
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Not fixed with latest HA currently available.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Not fixed with latest HA currently available.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Not fixed with latest HA currently available: 2021.12.7
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Issue is still present, has never been addressed.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Issue is still present, has never been addressed.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Issue is still present, has never been addressed.
I can confirm the issue still exists. It seems to only happen when navigating to a page that's already in cache.
Sorry, what do you mean by a navigate service call?
If you created a custom element to do the navigation, you can easily add a scroll to top to it?
Sorry, what do you mean by a navigate service call?
If you created a custom element to do the navigation, you can easily add a scroll to top to it?
I have hidden the default menubar and created my own navigation bar. Basically a horizontal stack at the bottom of the page where each button is a service call that directs to a tab in a dashboard. All works well function wise. I made a video where I showed what I mean in my original post.
So basically: when you use a service call in a card (like button-card) you can navigate to a specific tab in a dashboard. When you scroll on that new tab down (or up), and then go back to the previous tab by another service-call, the previous tab is also scrolled down (or up)
Example: I open my dashboard in tab 1. I then use a button with service call to navigate to tab 2. In tab 2 I scroll down the page. Then I go to tab 1 by again using a button with a service call. Then tab 1 is also somehow scrolled down, like tab 2 was. While tab 1 was never controlled. It should either remember the position of the previous tab OR reload the tab and go to the top automatically like the menubar behaves.
Might be some caching issue, where controlling a tab that has been opened through service call, also controls the previous tab.
That is not a service call, but I get what you mean.
That is not a service call, but I get what you mean.
Aren't they called service calls by HA documentation?: https://www.home-assistant.io/docs/scripts/service-calls/
In my case I use navigate and url of a specific tab as a service call with custom button-card. Or does this have a different name with what I mean?
The issue can be replicated by adding a button card with e.g. a tap action using navigate
and for example navigation_path: "/lovelace/my_subview"
.
When navigating between the views and scrolling in between, the scroll position is not correctly restored by the frontend (tested with desktop browser in addition to iOS). For example:
/lovelace/my_subview
That's the bug. In my opinion the correct behavior would be that in the example step 3, UI went back to default dashboard back at scroll position 100px from top. So practically the same what @ASNNetworks described.
I'm sure this can be fixed with some combination, but it could be a bit problematic to release as some might rely on this behavior.
I investigated this further within my own HA dev environment.
History.scrollRestoration is 'auto' by default and not overridden within HA frontend so browser will try and restore the scroll position.
When testing how scrollRestoration should work with my own minimal HTML (copied at the bottom of this post if interested), I noticed browser requires a precise sequencing of history.pushState
vs rendering new content to DOM. My example HTML at the bottom works as "regular" static websites (no history.pushState or dynamic DOM content) do.
Possible fix ideas that came to my mind:
manual
and implement a new mechanism in HA frontend to save and restore previous scroll positions.To solve my immediate pain, I implemented a pretty horrible hack. I do not recommend copying this, but sharing it here if it helps solving the core issue. In our default dashboard, I added a visually hidden button-card custom card which allows running arbitrary JS in the user's browser once the page is loaded. In that JS I monkey patch the global window.history.pushState
to implement the second fix I suggested above.
type: custom:button-card
styles:
card:
- height: 0px
- opacity: 0
name: |
[[[
if (!window.__monkeyPatchDone) {
window.__previousScrollY = 0;
const originalPushState = window.history.pushState;
window.history.pushState = (state, unused, url) => {
console.log('Monkey patched pushState called!')
window.__previousScrollY = window.scrollY;
originalPushState.apply(window.history, [state, unused, url]);
setTimeout(() => window.scrollTo({ top: 0 }), 1)
}
window.addEventListener('popstate', (event) => {
// This trick covers user bouncing back and forward
const currScrollY = window.scrollY;
const prevScrollY = window.__previousScrollY
window.__previousScrollY = currScrollY;
if (Number.isFinite(prevScrollY)) {
setTimeout(() => {
window.scrollTo({
top: prevScrollY
})
console.log(`Scrolled to ${prevScrollY}`);
}, 5);
setTimeout(() => console.log('Scroll now', window.scrollY), 200)
}
});
window.history.scrollRestoration = 'manual';
window.__previousScrollY = window.scrollY;
console.log('Monkey patch done!')
}
window.__monkeyPatchDone = true;
]]]
The issue is still present... Subviews are really cool and they help organize the dashboard heavily. It should be fixed somehow, please!
I'd love to see this issue fixed too.
@MasterDevwi @raidolo @kimmobrunfeldt @blair287
There is a new HACS module since 2 weeks, I just found about it now which solves exactly this issue.
https://github.com/elchininet/lovelace-autoscroll
It automatically scrolls to the top when switching to a new tab. The latest 3.0 release only works on HA 2023.4. The version before that, works on 2023.3.6 as well. I haven't updated yet to 2023.4 because of some major breaking changes with button-card, decluttering-card and card-mod themes. But I can confirm the version below 3.0 works great on HA 2023.3.6
I will leave this open however, since I believe this is something HA Core should fix properly.
@MasterDevwi @raidolo @kimmobrunfeldt @blair287
There is a new HACS module since 2 weeks, I just found about it now which solves exactly this issue.
https://github.com/elchininet/lovelace-autoscroll
It automatically scrolls to the top when switching to a new tab. The latest 3.0 release only works on HA 2023.4. The version before that, works on 2023.3.6 as well. I haven't updated yet to 2023.4 because of some major breaking changes with button-card, decluttering-card and card-mod themes. But I can confirm the version below 3.0 works great on HA 2023.3.6
I will leave this open however, since I believe this is something HA Core should fix properly.
Nice!! Thanks, I'll try it soon.
I've updated to 2023.4.1 and I don't have the issue anymore, I've installed the lovelace-autoscroll, but I was testing the default behavior of the April release and it seems it has been fixed somehow. I've removed the lovelace-autoscroll plugin and it seems that even without it, now the pages load at the top of the page. Could anyone else confirm?
I just tried it and it seems to be working now as well. 😮 🎆
For me it Core hasn't changed anything, just updated to 2023.4.1 from 2023.3.6 and the behaviour is exactly the same. I wonder if you guys still have auto-scroll cached, I know it took me a good amount of cache clearing to finally load up some updated cards.
Sadly, the auto-scroll module seems to be broken as well (tried 3.0 with 2023.4.1). Many custom modules/cards seem to suffer currently, so hopefully things will be fixed the coming weeks. Reported the ticket.
For me it Core hasn't changed anything, just updated to 2023.4.1 from 2023.3.6 and the behaviour is exactly the same. I wonder if you guys still have auto-scroll cached, I know it took me a good amount of cache clearing to finally load up some updated cards.
Sadly, the auto-scroll module seems to be broken as well (tried 3.0 with 2023.4.1). Many custom modules/cards seem to suffer currently, so hopefully things will be fixed the coming weeks. Reported the ticket.
You were right, it was probably cached somehow. It's back to the original behavior now. I'll look into autoscroll again...
Well it's weird, sometimes it goes at the top sometimes not. I can't really see a pattern here... I believe they did something, like the autoscroll's dev said in your ticket.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.
Checklist
The problem
I created my own tab bar using button cards in a horizontal stack, to emulate the default tabs. Each button has a service call that navigates to a lovelace page in that dashboard.
When scrolling through Lovelace and using a navigate service call to a different tab, the new tab starts at the same location as where the previous tab stopped. So for instance: when I open tab A and scroll all the way to the bottom, and then open tab B then I'm at the bottom of tab B as well.
See video of the problem: https://user-images.githubusercontent.com/54230480/105841558-15011f80-5fd5-11eb-8b89-7133f49b4a39.mp4
Expected behavior
Each tab should either remember where that tab was ended, or it should always start at the top when navigating to a new tab. Right now it remember where the previous tab was and starts at that same location on the new tab. It should work the same as how Lovelace tabs work.
Steps to reproduce
Environment
Additional information
I use button cards to navigate through my dashboard. This bug only occurs when using the navigate service call.