iOS: 'back' goes to wrong position in topics list

The ‘back’ function in Safari/iOS (iPhone 8, latest iOS version) is unreliable; when going from the topic list to a topic, it will often not take you back to the correct position in the topic list. On my own forum this happens pretty much always. On Meta, it sometimes works for me, but more often it doesn’t. This happens both when clicking the ‘back’ button and when swiping to the right.

4 Likes

Out of curiosity does it work in safe mode ?

3 Likes

Sorry I forgot to mention that: I tested safe mode both on my own forum and here on Meta with the same result.

1 Like

In the iOS hub app or in native mobile safari? I can’t repro any problem using the back button or back swipe from the topic list here on meta.

Do you have specific repro steps?

Oh wait, I can repro for back swipe, but not back button. Back swipe doesn’t seem to remember the actual scroll position in the topic list, but back button always does.

4 Likes

In native mobile safari. At first I had a hunch it was related to the topic list refreshing, but that doesn’t seem to be the case. It happens 100% of the time for me on Meta now.

Repro steps:

  • Log in to Meta
  • Reload the Meta homepage (this step doesn’t seem necessary but I wanted to rule out the topic list refresh issue)
  • Scroll one page down
  • Select a topic
  • Swipe right or click back

I also tried the following, all with the same result:

  • Disabled the Crystal ad blocker in content blocking.
  • Opened Meta in a private tab without logging in.
  • Tested on an iPhone SE.
  • Tested in Chrome on a Galaxy S6
5 Likes

That does seem to repro for me @eviltrout … perhaps we regressed here? @joffreyjaffeux?

6 Likes

This should fix it:

https://github.com/discourse/discourse/pull/8624

Details inside commit message, will wait for robin approval before merging this next week. Thanks for detailed report :+1:

11 Likes

This is merged, let me know how it goes please.

6 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.

After a discussion with @bartv I investigated more and discovered that there is indeed a regression.

I think it’s coming from:

https://github.com/discourse/discourse/commit/054fbd7846546ae68a5703d47e1750db1bc34ffd

Basically in this case, scrollOnLoad is undefined:
https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/components/topic-list.js.es6#L71

I suggest the following fix:
https://github.com/discourse/discourse/pull/8661

Can you review next week @markvanlan please?

10 Likes

@bartv I just merged the second fix, please let me know how it goes when you get some time.

As a side note, I wonder if we couldn’t improve this logic even more? ATM it’s storing the position of one topic at each page scroll, but especially on mobile it can mean that when you come back the topic you clicked on is not in viewport, even if not very far.

5 Likes

I just tested here on Meta but it doesn’t work for me - when I tap ‘back’ from a topic, I return to the top of the topics list.

And +1 to returning to the exact position in the topic list.

It does work for me, please make a video when you have time.

2 Likes

I added it to my post. Hope it helps, let me know if you need me to include other things.

1 Like

What the video shows is expected, you didn’t do a « page scroll », as in it did’t load more topics, so it didn’t update last seen topic position.

This is what my sidenote proposed to improve.

3 Likes

Ah, I can confirm that it DOES work when I scroll down far enough to force new topics loading. I didn’t expect that limitation - as a user that’s a little confusing/inconsistent.

1 Like

Yes I don’t like it that much too, hence why I proposed we improved it. But AFAIK this is not a regression as the other things I fixed.

4 Likes

Damn there was indeed another regression from this commit and I think this should solve it:

https://github.com/discourse/discourse/commit/7f00cefcac60147faca056a92f1eddb0b5ac1829

and bring the behavior we were talking of!

6 Likes