Skip to content

Commit dcd4bf5

Browse files
committed
Mouse wheel scrolling and scroll-reset on settings page
1 parent 2df87de commit dcd4bf5

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

frontend/src/app/pages/settings/Settings.tsx

+28-3
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ const Settings = () => {
236236
if (latestVersion === app.system.version)
237237
openModal("No Updates available.", "Check back again later :)", null, null)
238238
else {
239-
openModal( "New update available!", `Current: ${app.system.version} \n\n Latest: ${latestVersion}`, "UPDATE NOW", () => systemTask('update'))
239+
openModal("New update available!", `Current: ${app.system.version} \n\n Latest: ${latestVersion}`, "UPDATE NOW", () => systemTask('update'))
240240
}
241241
} catch (error) {
242242
openModal("Error checking for updates:", error, null, null)
@@ -318,7 +318,7 @@ const Settings = () => {
318318
))
319319
//console.log(content.options, dataOptions)
320320
//console.log(dropdown)
321-
321+
322322
// Check for boolean setting
323323
const isBoolean = typeof value === 'boolean'; // Checks if the setting is a boolean.
324324
const isBinding = key.includes('bindings') // Checks if the setting handles bindings
@@ -415,6 +415,30 @@ const Settings = () => {
415415
}
416416

417417

418+
//Fixing Mouse Wheel Scrolling for IndianaScroll.
419+
const scrollRef = useRef(null);
420+
421+
// Make sure wheel event is always attached after every render.
422+
useEffect(() => {
423+
const handleWheel = (event) => {
424+
if (scrollRef.current) {
425+
scrollRef.current.scrollTop += event.deltaY; // Scrolls vertically
426+
}
427+
};
428+
429+
const container = scrollRef.current;
430+
if (container) {
431+
container.addEventListener("wheel", handleWheel);
432+
}
433+
434+
return () => {
435+
if (container) {
436+
container.removeEventListener("wheel", handleWheel);
437+
}
438+
};
439+
}, [system.settingPage]); // Make sure useEffect runs again on reset
440+
441+
418442
return (
419443
<Container>
420444
<ScrollContainer
@@ -423,7 +447,8 @@ const Settings = () => {
423447
horizontal={false}
424448
hideScrollbars={true}
425449
ignoreElements='input, select'
426-
key={JSON.stringify(reset)}
450+
key={`${system.settingPage}-${reset}`} // This will force a complete re-render when page changes
451+
innerRef={scrollRef}
427452
>
428453
{system.settingPage === 1 &&
429454
<>

0 commit comments

Comments
 (0)