mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 23:16:03 +01:00
feat(web/input): submit on enter press
This commit is contained in:
@@ -17,6 +17,7 @@ import InputNumber from "./components/number";
|
||||
import Input from "./components/input";
|
||||
import CheckboxField from "./components/checkbox";
|
||||
import SelectField from "./components/select";
|
||||
import { useKeyPress } from "../../hooks/useKeyPress";
|
||||
|
||||
interface Props {
|
||||
heading: string;
|
||||
@@ -58,9 +59,13 @@ const InputDialog: React.FC = () => {
|
||||
>([]);
|
||||
const [passwordStates, setPasswordStates] = React.useState<boolean[]>([]);
|
||||
const [visible, setVisible] = React.useState(false);
|
||||
|
||||
const enterPressed = useKeyPress("Enter");
|
||||
const { locale } = useLocales();
|
||||
|
||||
React.useEffect(() => {
|
||||
if (visible && enterPressed === false) handleConfirm();
|
||||
}, [enterPressed]);
|
||||
|
||||
const handlePasswordStates = (index: number) => {
|
||||
setPasswordStates({
|
||||
...passwordStates,
|
||||
|
||||
Reference in New Issue
Block a user