Prevent mouse wheel window scrolling on other number fields (#5283)

This commit is contained in:
WithoutPants
2024-09-22 15:24:54 +10:00
committed by GitHub
parent 4ad0241c53
commit 33050f700e
11 changed files with 42 additions and 24 deletions

View File

@@ -12,6 +12,7 @@ import { FormattedMessage, FormattedNumber, useIntl } from "react-intl";
import useFocus from "src/utils/focus";
import { Icon } from "../Shared/Icon";
import { faCheck, faChevronDown } from "@fortawesome/free-solid-svg-icons";
import { useStopWheelScroll } from "src/utils/form";
const PageCount: React.FC<{
totalPages: number;
@@ -32,6 +33,8 @@ const PageCount: React.FC<{
}
}, [showSelectPage, pageFocus]);
useStopWheelScroll(pageInput);
const pageOptions = useMemo(() => {
const maxPagesToShow = 10;
const min = Math.max(1, currentPage - maxPagesToShow / 2);
@@ -98,6 +101,7 @@ const PageCount: React.FC<{
<Popover id="select_page_popover">
<Form inline>
<InputGroup>
{/* can't use NumberField because of the ref */}
<Form.Control
type="number"
min={1}