accept enter as save event in account name setting
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { Button, Dialog, DialogActions, DialogTitle } from "@mui/material";
|
import { Button, Dialog, DialogActions, DialogTitle } from "@mui/material";
|
||||||
import { AccessToken, CharacterUpdate } from "../../../types";
|
import { AccessToken, CharacterUpdate } from "../../../types";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState, KeyboardEvent } from "react";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
import { revokeToken } from "@/esi-sso";
|
import { revokeToken } from "@/esi-sso";
|
||||||
|
|
||||||
@@ -27,6 +27,13 @@ export const CharacterDialog = ({
|
|||||||
.catch((e) => console.log("Logout failed"));
|
.catch((e) => console.log("Logout failed"));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
|
||||||
|
if (event.key === "Enter") {
|
||||||
|
character && updateCharacter(character, { account });
|
||||||
|
closeDialog();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={character !== undefined} onClose={closeDialog}>
|
<Dialog open={character !== undefined} onClose={closeDialog}>
|
||||||
<DialogTitle>{character && character.character.name}</DialogTitle>
|
<DialogTitle>{character && character.character.name}</DialogTitle>
|
||||||
@@ -37,6 +44,7 @@ export const CharacterDialog = ({
|
|||||||
value={account ?? ""}
|
value={account ?? ""}
|
||||||
sx={{ margin: 1 }}
|
sx={{ margin: 1 }}
|
||||||
onChange={(event) => setAccount(event.target.value)}
|
onChange={(event) => setAccount(event.target.value)}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button
|
<Button
|
||||||
|
Reference in New Issue
Block a user