Android: Using the "back" functionality, the state of the collection page is lost
Describe the bug Basically #13 but for the "back" button, which most Android either have physically or with a gesture.
To Reproduce Steps to reproduce the behavior:
- Go to the collections, swipe right on one
- Click on any article but the first one
- Use the "back" button
- See that collection page state (horizontal scrolling position) is lost
Exception: If you have used the "back" icon inside the footer ONCE, it will always work. Easily reproducable by just closing the app and starting at 1.
Expected behavior The state of the collections page should be preserved even for first time going back via the "button"
Screenshots
Smartphone (please complete the following information):
- Device: Any Android
- OS: Android 12
- Browser: Internal App Browser
- Version: 1.2.1 (of the app)
Additional context Ionic article about the back button of Android: https://ionicframework.com/docs/developing/hardware-back-button#basic-usage
My two cents: I think adding the code from the article above here would resolve the issue: https://github.com/aerotoad/Thud/blob/a5e7b8e441a180f7a10f1c061e7546b811b8e7a2/src/app/pages/entry/entry.page.ts#L76
this.platform.backButton.subscribeWithPriority(10, () => {
goBack();
});
I have not seen that you have registered ANY handler for the back button, so I guess Ionic just does a browser back and loses the state that way. Not sure though.
<3 your app by the way.
I'm planning on a full rewrite of the scrolling both horizontal and vertical of the grid view to use a better virtual scroll system that'll allow better performance when a collection is full. The current implementation can and does get laggy. After this is done, I'll implement some sort of mechanism to store and restore scroll position for every row when opening an article. This should address your issue.
@aerotoad Thx for the answer.
I never experienced any issues with the scrolling, but then again I do look into the app regularly and only have small feed updates until reach already read tiles.
Anyhow, I am not sure that a rewrite solves my problem. The right functionality is there already. It just does not seem to be triggered in that particular case.
Can you reproduce the issue on your site?
I am not familiar with Android development and I am not sure if I can setup a dev environment on my site. If I create a PR with the changes I think need to be done for this to work, would you be willing to test it? This of course only works if you can reproduce the problem on your site in the first place :D
@func0der I've spotted the problem and it seems to be corrected. I've been working on that rework of the scrolling I mentioned and now the scroll state is correctly memoized when navigating back from an article. Expect the fix to be in the next release.