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

**URL:** https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770
**Category:** Bug
**Created:** [December 21, 2019, 12:43pm UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770 "2019-12-21T12:43:56Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [December 21, 2019, 12:43pm UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/1 "2019-12-21T12:43:56Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [December 21, 2019, 1:00pm UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/2 "2019-12-21T13:00:18Z")

</div>

Out of curiosity does it work in [safe mode](https://meta.discourse.org/t/53504?silent=true) ?

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [December 21, 2019, 1:09pm UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/3 "2019-12-21T13:09:11Z")

</div>

Sorry I forgot to mention that: I tested [safe mode](https://meta.discourse.org/t/53504?silent=true) both on my own forum and here on Meta with the same result.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [December 22, 2019, 2:15am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/4 "2019-12-22T02:15:43Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [December 22, 2019, 7:29am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/5 "2019-12-22T07:29:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [December 22, 2019, 6:39pm UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/6 "2019-12-22T18:39:43Z")

</div>

> [@bartv](#):
>
> - 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

That does seem to repro for me @eviltrout .. perhaps we regressed here? @j.jaffeux?

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [December 29, 2019, 6:38pm UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/8 "2019-12-29T18:38:07Z")

</div>

This should fix it:

[https://github.com/discourse/discourse/pull/8624](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 👍

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [December 30, 2019, 7:36am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/9 "2019-12-30T07:36:42Z")

</div>

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

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [January 2, 2020, 7:36am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/10 "2020-01-02T07:36:51Z")

</div>

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

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [January 4, 2020, 9:38am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/11 "2020-01-04T09:38:34Z")

</div>



---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [January 4, 2020, 9:40am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/12 "2020-01-04T09:40:29Z")

</div>

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](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](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](https://github.com/discourse/discourse/pull/8661)

Can you review next week @markvanlan please?

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [January 6, 2020, 2:45pm UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/13 "2020-01-06T14:45:26Z")

</div>

@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.

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [January 7, 2020, 8:36am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/14 "2020-01-07T08:36:12Z")

</div>

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.

[https://global.discourse-cdn.com/meta/original/3X/d/a/dad1a059b6fe43f631834df24cce1a99561b9743.MP4](https://global.discourse-cdn.com/meta/original/3X/d/a/dad1a059b6fe43f631834df24cce1a99561b9743.MP4)

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [January 7, 2020, 8:38am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/15 "2020-01-07T08:38:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [January 7, 2020, 8:39am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/16 "2020-01-07T08:39:52Z")

</div>

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

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [January 7, 2020, 8:41am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/17 "2020-01-07T08:41:25Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [January 7, 2020, 8:43am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/18 "2020-01-07T08:43:22Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [January 7, 2020, 8:44am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/19 "2020-01-07T08:44:08Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [January 7, 2020, 11:49am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/20 "2020-01-07T11:49:46Z")

</div>

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

[https://github.com/discourse/discourse/commit/7f00cefcac60147faca056a92f1eddb0b5ac1829](https://github.com/discourse/discourse/commit/7f00cefcac60147faca056a92f1eddb0b5ac1829)

and bring the behavior we were talking of!

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [January 7, 2020, 11:49am UTC](https://meta.discourse.org/t/ios-back-goes-to-wrong-position-in-topics-list/136770/21 "2020-01-07T11:49:50Z")

</div>


