Skip to content

Commit

Permalink
Prevent the Enter key from submitting the form when text input has fo…
Browse files Browse the repository at this point in the history
…cus (#2404)

* Include our NFT collection in option list for signing (#2394)

* Prevent the Enter key from submitting the form when text input has focus (#2394)
  • Loading branch information
markelrod authored Jun 27, 2024
1 parent fd3e017 commit c2354a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/gui/src/components/signVerify/SignMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,21 @@ export default function SignMessage(props: SignMessageProps) {
await handleSign();
}

const preventEnterKeySubmission = (e: React.KeyboardEvent<HTMLFormElement>) => {
const { target } = e;
if (e.key === 'Enter' && target instanceof HTMLInputElement) {
e.preventDefault();
}
};

const buttons: { type: SignMessageEntityType; label: ReactNode }[] = [
{ type: SignMessageEntityType.WalletAddress, label: <Trans>Wallet Address</Trans> },
{ type: SignMessageEntityType.NFT, label: <Trans>NFT</Trans> },
{ type: SignMessageEntityType.DID, label: <Trans>DID</Trans> },
];

return (
<Form methods={methods} onSubmit={handleSubmit}>
<Form methods={methods} onSubmit={handleSubmit} onKeyDown={preventEnterKeySubmission}>
<Flex flexDirection="column" gap={3}>
<Card>
<Flex flexDirection="column" gap={1}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default function SigningEntityNFT(props: SigningEntityNFTProps) {
label={<Trans>NFT ID</Trans>}
variant="filled"
name={entityFormName}
includeNFTCollection
InputProps={{
endAdornment: (
<InputAdornment position="end">
Expand Down

0 comments on commit c2354a1

Please sign in to comment.