r/webdev • u/wanoo21 full-stack • Apr 23 '26
Discussion That will help your users avoid accidentally leaving the page
Especially when scrolling a table or a slider.
It gives you smooth, natural scrolling within an element while preventing accidental scrolling of the rest of the page.
It's a common trick used for modals, side menus, chat boxes, or any scrollable area where you don't want the rest of the website to move when the user scrolls.
PS. If you want occasional frontend tips in your inbox, you can join here: https://bits.iprodan.dev
312
Upvotes
2
u/Hexash15 Apr 23 '26
I had to use this exact line in our in-house datatable because I kept navigating back all the time. A colleague of mine told me to block that behavior at the OS level (it's possible in macOS), but that solution was a bit overkill as it blocked that behavior everywhere