Skip to content

Commit

Permalink
fix: number input on firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
VampireChicken12 committed Sep 10, 2023
1 parent 11a491d commit 6769f6e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/components/Inputs/Number/Number.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.number::-webkit-inner-spin-button,
.number::-webkit-outer-spin-button {
-webkit-appearance: none;
appearance: none;
}
18 changes: 2 additions & 16 deletions src/components/Inputs/Number/Number.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ChangeEvent, MutableRefObject, useRef, useEffect } from "react";
import React, { ChangeEvent, MutableRefObject, useRef } from "react";
import "./Number.css";
import Arrow from "./Arrow";
interface NumberInputProps {
Expand Down Expand Up @@ -38,21 +38,6 @@ const NumberInput: React.FC<NumberInputProps> = ({ value, min = 0, max = undefin
onChange({ currentTarget: { value } } as ChangeEvent<HTMLInputElement>);
}
};
useEffect(() => {
// TODO: get working in popup if possible
const mouseEnter = () => {
window.document.body.style.overflow = "hidden";
};
const mouseLeave = () => {
window.document.body.style.overflow = "auto";
};
inputDiv.current?.addEventListener("mouseenter", mouseEnter);
inputDiv.current?.addEventListener("mouseleave", mouseLeave);
return () => {
inputDiv.current?.removeEventListener("mouseenter", mouseEnter);
inputDiv.current?.removeEventListener("mouseleave", mouseLeave);
};
}, [inputDiv]);

return (
<div className={`${className ? `${className} ` : ""} relative flex mb-2 gap-4 items-baseline justify-between flex-row`} ref={inputDiv}>
Expand All @@ -72,6 +57,7 @@ const NumberInput: React.FC<NumberInputProps> = ({ value, min = 0, max = undefin
step={step}
style={{
WebkitAppearance: "none",
MozAppearance: "textfield",
borderTopLeftRadius: "0.375rem",
borderBottomLeftRadius: "0.375rem",
...(disabled ? { color: "#4b5563" } : {})
Expand Down

0 comments on commit 6769f6e

Please sign in to comment.