mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-24 06:32:08 -05:00
parent
b2a222d7e8
commit
74e786053e
1 changed files with 20 additions and 2 deletions
|
@ -5,7 +5,13 @@ import { useHistory, useParams } from "react-router-dom";
|
||||||
import styles from "./Settings.module.scss";
|
import styles from "./Settings.module.scss";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { Text } from "preact-i18n";
|
import { Text } from "preact-i18n";
|
||||||
import { useCallback, useContext, useEffect, useState } from "preact/hooks";
|
import {
|
||||||
|
useCallback,
|
||||||
|
useContext,
|
||||||
|
useEffect,
|
||||||
|
useRef,
|
||||||
|
useState,
|
||||||
|
} from "preact/hooks";
|
||||||
|
|
||||||
import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice";
|
import { isTouchscreenDevice } from "../../lib/isTouchscreenDevice";
|
||||||
|
|
||||||
|
@ -74,6 +80,8 @@ export function GenericSettings({
|
||||||
return () => document.body.removeEventListener("keydown", keyDown);
|
return () => document.body.removeEventListener("keydown", keyDown);
|
||||||
}, [exitSettings]);
|
}, [exitSettings]);
|
||||||
|
|
||||||
|
const pageRef = useRef<string>();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(styles.settings, {
|
className={classNames(styles.settings, {
|
||||||
|
@ -155,7 +163,17 @@ export function GenericSettings({
|
||||||
)}
|
)}
|
||||||
{(!isTouchscreenDevice || typeof page === "string") && (
|
{(!isTouchscreenDevice || typeof page === "string") && (
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
<div className={styles.scrollbox}>
|
<div
|
||||||
|
className={styles.scrollbox}
|
||||||
|
ref={(ref) => {
|
||||||
|
// Force scroll to top if page changes.
|
||||||
|
if (ref) {
|
||||||
|
if (pageRef.current !== page) {
|
||||||
|
ref.scrollTop = 0;
|
||||||
|
pageRef.current = page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}>
|
||||||
<div className={styles.contentcontainer}>
|
<div className={styles.contentcontainer}>
|
||||||
{!isTouchscreenDevice &&
|
{!isTouchscreenDevice &&
|
||||||
!pages.find(
|
!pages.find(
|
||||||
|
|
Loading…
Reference in a new issue