How to prevent scroll-to-top on parent page after form submission?

When a record-editing form (modal or not) is called from a grid and the record submit rule is set to return to the parent page, the parent page always scrolls back up to the top, which is super annoying when you had scrolled far down a long grid to locate the record you wanted to change. Any ideas on how to prevent this?

I have tried a few things such as the following, but that would require setting the scrollPostion before the rendering of my form and I don’t know how to approach that.

// Before submission
sessionStorage.setItem('scrollPosition', window.pageYOffset);

// After page reload
var scrollPosition = sessionStorage.getItem('scrollPosition');
if (scrollPosition) {
  window.scrollTo(0, scrollPosition);
  sessionStorage.removeItem('scrollPosition');
}

Thanks in advance.

Easily achievable using the KTL created by @NormandDefayette_CortexRD. I use _cmr on most of my modals (close modal refresh)

Setting up the Configurator

1 Like

I thought the below may help if you’re thinking of exploring some of the very useful keywords in KTL

1 Like

+1 recommendation for KTL.
This feature, hide columns based on user roles, and Bulk Edit and Bulk Delete are enough user value to get started learning KTL. IMO

2 Likes

Agreed - I was reluctant 18 months ago as I didn’t understand it and was worried about the unknown.

@NormandDefayette_CortexRD persisted and supported me, and now it’s part of every client app.

I wouldn’t want to be without the extra functionality and power that KTL brings to Knack.

2 Likes

Thanks! I am using the KTL but had not discovered this keyword yet. Just what I need!

2 Likes

Excellent, I’m glad that I drew it to your attention.

I use _cmr on almost every modal nowadays. I feel it provides a more polished user experience.

Thanks to my good friend @NormandDefayette_CortexRD for his continued hard work with KTL. :rocket:

2 Likes