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

HidekiOgawa
Tera Guru

Scrolling is possible by calling the following client script:

 

function handler({api, event, helpers, imports}) {
    helpers.timing.setTimeout(function (){
        this.top.window.scroll({
            top: 0,
            behavior: "smooth",
        });
    }, 100);
}

 

valter479
Tera Contributor

Hi @HidekiOgawa ,

 

Looks like nothing happen.

 

I have an form, actually the catalog item component, after submit the form if validation fails, an event is trigger (it shows alert notification at the top of the page). I added an event handler that runs a client script with the code that you provided.

 

Any idea why it is not working?

 

Thanks.

Hi @valter479,

You can try this in your client handler:

function handler({helpers}) {
  helpers.timing.setTimeout(() => {
    window.scrollTo({
      top: 0,
      behavior: 'smooth'
    });
  }, 100);
}

Regards,

Ehab Pilloor

HI @Ehab Pilloor ,

window is undefined. 

 

I tried "this.window.scrollTo(...)" and this.window.scroll(...)" but both didn't worked.

 

Thanks,

Valter