# Scroll to the top of pop up every time it's opened?

**URL:** <https://forum.bubble.io/t/scroll-to-the-top-of-pop-up-every-time-its-opened/335306>\
**Category:** Need help\
**Created:** [August 14, 2024, 5:57pm UTC](https://forum.bubble.io/t/scroll-to-the-top-of-pop-up-every-time-its-opened/335306 "2024-08-14T17:57:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![northstar](https://avatars.discourse-cdn.com/v4/letter/n/f475e1/32.png) [@northstar](https://forum.bubble.io/u/northstar)\
**Post date:** [August 14, 2024, 5:57pm UTC](https://forum.bubble.io/t/scroll-to-the-top-of-pop-up-every-time-its-opened/335306/1 "2024-08-14T17:57:45Z")

</div>

Hey there, I have a page where users can click on a home and it will bring up a pop up with that persons profile. Only problem I’m having is that when a user closes that pop up and clicks on another one it will stay at the position of where the user left the last one i.e middle of the pop up.

Does anyone know how I can make it so every time that pop up is clicked it will scroll to the top of of the pop up?

---

<div class="post-metadata">

**Author:** ![code-escapee](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/code-escapee/32/195485_2.png) [@code-escapee](https://forum.bubble.io/u/code-escapee)\
**Post date:** [August 14, 2024, 6:10pm UTC](https://forum.bubble.io/t/scroll-to-the-top-of-pop-up-every-time-its-opened/335306/2 "2024-08-14T18:10:55Z")

</div>

reset the popup each time on close or upon open set focus to the top element?

---

<div class="post-metadata">

**Author:** ![sem](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sem](https://forum.bubble.io/u/sem)\
**Post date:** [August 15, 2024, 4:41am UTC](https://forum.bubble.io/t/scroll-to-the-top-of-pop-up-every-time-its-opened/335306/3 "2024-08-15T04:41:04Z")

</div>

Scroll to and set page offset to 0? This will bring your view all the way to your top

---

<div class="post-metadata">

**Author:** ![northstar](https://avatars.discourse-cdn.com/v4/letter/n/f475e1/32.png) [@northstar](https://forum.bubble.io/u/northstar)\
**Post date:** [August 15, 2024, 10:14am UTC](https://forum.bubble.io/t/scroll-to-the-top-of-pop-up-every-time-its-opened/335306/4 "2024-08-15T10:14:54Z")

</div>

Thanks guys. I’ve tried reseting the pop up like below but it’s not doing anything:

 ![Screenshot 2024-08-15 at 11.13.16](https://us1.discourse-cdn.com/bubble/original/3X/b/6/b6556dd16544724fa183cfb6e4c5db3143a6dc4e.png)

I’m unable to do the second suggestion as the user is viewing homes so needs to stay at the same position as they started rather than go to the top.

Don’t suppose anyone has an other ideas?

---

<div class="post-metadata">

**Author:** ![code-escapee](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/code-escapee/32/195485_2.png) [@code-escapee](https://forum.bubble.io/u/code-escapee)\
**Post date:** [August 15, 2024, 4:22pm UTC](https://forum.bubble.io/t/scroll-to-the-top-of-pop-up-every-time-its-opened/335306/5 "2024-08-15T16:22:18Z")

</div>

To clarify above, Set focus to top element in the popup

---

<div class="post-metadata">

**Author:** ![northstar](https://avatars.discourse-cdn.com/v4/letter/n/f475e1/32.png) [@northstar](https://forum.bubble.io/u/northstar)\
**Post date:** [August 23, 2024, 3:29pm UTC](https://forum.bubble.io/t/scroll-to-the-top-of-pop-up-every-time-its-opened/335306/6 "2024-08-23T15:29:45Z")

</div>

Thanks man, still can’t get it to work ☹ I spoke to bubble and they said it had something to do with the custom code of the pop up:

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/3/9/397955dd44b1798aa3b00511f64462aa0868a748.png)

The first part is so that the pop up is full width & height. The second part is to have a floating group within it for easy exit.

I don’t suppose you know what in the code is blocking this?

---

<div class="post-metadata">

**Author:** ![code-escapee](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/code-escapee/32/195485_2.png) [@code-escapee](https://forum.bubble.io/u/code-escapee)\
**Post date:** [August 23, 2024, 4:04pm UTC](https://forum.bubble.io/t/scroll-to-the-top-of-pop-up-every-time-its-opened/335306/7 "2024-08-23T16:04:56Z")

</div>

Try chatGPT

---

<div class="post-metadata">

**Author:** ![northstar](https://avatars.discourse-cdn.com/v4/letter/n/f475e1/32.png) [@northstar](https://forum.bubble.io/u/northstar)\
**Post date:** [August 24, 2024, 10:54am UTC](https://forum.bubble.io/t/scroll-to-the-top-of-pop-up-every-time-its-opened/335306/8 "2024-08-24T10:54:12Z")

</div>

Thanks mate! All sorted now, the issue was coming from the run javascript code, it was not resetting the scrolling position when the pop up was opened and closed. To solve it:

Amended code for when pop up is opened:  
savedScrollY = window.scrollY;  
let x = document.getElementById(“TA”);  
x.style.position = “fixed”;  
x.style.top = -savedScrollY + “px”;

// Reset the scroll position to the top  
document.getElementById(“TC”).scrollTop = 0;

Amended code for when pop up is closed:  
let x = document.getElementById(“TA”);  
x.style.position = “absolute”;  
x.style.top = “”;  
window.scrollBy(0, savedScrollY);  
document.getElementById(“TC”).scrollTop = 0; // This ensures the scroll position is reset when the pop-up is closed

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [October 23, 2024, 5:58pm UTC](https://forum.bubble.io/t/scroll-to-the-top-of-pop-up-every-time-its-opened/335306/9 "2024-10-23T17:58:31Z")

</div>

Closed on October 23, 2024, 5:58pm UTC

This topic was automatically closed after 70 days. New replies are no longer allowed.
