UI Builder - scroll to the top of the page

valter479
Tera Contributor

On UI Builder is possible to scroll to the top of the page. 

9 REPLIES 9

@valter479 

If you are using a web component or container, then try adding it to script with following logic

function handler({helpers}) {
  helpers.timing.setTimeout(() => {
    const container = document.querySelector('ADD_YOUR_CONTAINER_NAME'); 
    if (container) {
      container.scrollTo({
        top: 0,
        behavior: 'smooth'
      });
    }
  }, 100);
}

 

Regards,

Ehab Pilloor

That's because window is not in the this. scope. Like if you type this. it will bring up a list of valid options to dot walk. Window is not one of them. Top is and dot walking top to window is not either. It's a really limited list (ApiHelpers, api, behavior, event, handler, helpers, imports, params, setTimeout, timing, top). Really feel like they have tied one hand behind our backs.

DavidSchmidtII
Tera Contributor

I've been playing with this a little, and you get document is undefined. Seems UI Builder doesn't recognize it. I did try your first code. It's valid so far as the syntax checker. But it doesn't do anything for me.

DavidSchmidtII
Tera Contributor

Curious if the commented code at the top has something to do with the lack of functionality?

Screenshot 2025-06-20 130530.png

DavidSchmidtII
Tera Contributor

FYI I abandoned this and just went for making the tabs at the top fixed. I guess in doing some research in UI Builder this is more like client side and the tricks we were trying here require server side access.