diff options
author | Sebastian <sebasjm@gmail.com> | 2021-11-12 13:12:27 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2021-11-12 13:12:27 -0300 |
commit | 38b84bb8051db2f03b152d66c34a1cb4c8944a12 (patch) | |
tree | 1e7a23bacb5287a53da51f93faee8667292c56ee /packages/anastasis-webui/src/components/fields | |
parent | 377e78e8543b67c22798479fcf2d2f8d1dae5b28 (diff) | |
download | wallet-core-38b84bb8051db2f03b152d66c34a1cb4c8944a12.tar.xz |
fix #7059
Diffstat (limited to 'packages/anastasis-webui/src/components/fields')
4 files changed, 26 insertions, 2 deletions
diff --git a/packages/anastasis-webui/src/components/fields/DateInput.tsx b/packages/anastasis-webui/src/components/fields/DateInput.tsx index 0b6a7e316..18ef89908 100644 --- a/packages/anastasis-webui/src/components/fields/DateInput.tsx +++ b/packages/anastasis-webui/src/components/fields/DateInput.tsx @@ -1,4 +1,4 @@ -import { format, isAfter, parse, sub, subYears } from "date-fns"; +import { format, subYears } from "date-fns"; import { h, VNode } from "preact"; import { useLayoutEffect, useRef, useState } from "preact/hooks"; import { DatePicker } from "../picker/DatePicker"; @@ -9,6 +9,7 @@ export interface DateInputProps { tooltip?: string; error?: string; years?: Array<number>; + onConfirm?: () => void; bind: [string, (x: string) => void]; } @@ -44,7 +45,12 @@ export function DateInput(props: DateInputProps): VNode { type="text" class={showError ? "input is-danger" : "input"} value={value} - onInput={(e) => { + onKeyPress={(e) => { + if (e.key === 'Enter' && props.onConfirm) { + props.onConfirm() + } + }} + onInput={(e) => { const text = e.currentTarget.value; setDirty(true); props.bind[1](text); diff --git a/packages/anastasis-webui/src/components/fields/EmailInput.tsx b/packages/anastasis-webui/src/components/fields/EmailInput.tsx index fe676f284..4c35c0686 100644 --- a/packages/anastasis-webui/src/components/fields/EmailInput.tsx +++ b/packages/anastasis-webui/src/components/fields/EmailInput.tsx @@ -7,6 +7,7 @@ export interface TextInputProps { error?: string; placeholder?: string; tooltip?: string; + onConfirm?: () => void; bind: [string, (x: string) => void]; } @@ -37,6 +38,11 @@ export function EmailInput(props: TextInputProps): VNode { placeholder={props.placeholder} type="email" class={showError ? "input is-danger" : "input"} + onKeyPress={(e) => { + if (e.key === 'Enter' && props.onConfirm) { + props.onConfirm() + } + }} onInput={(e) => { setDirty(true); props.bind[1]((e.target as HTMLInputElement).value); diff --git a/packages/anastasis-webui/src/components/fields/NumberInput.tsx b/packages/anastasis-webui/src/components/fields/NumberInput.tsx index e1489eafa..4856131c7 100644 --- a/packages/anastasis-webui/src/components/fields/NumberInput.tsx +++ b/packages/anastasis-webui/src/components/fields/NumberInput.tsx @@ -7,6 +7,7 @@ export interface TextInputProps { error?: string; placeholder?: string; tooltip?: string; + onConfirm?: () => void; bind: [string, (x: string) => void]; } @@ -36,6 +37,11 @@ export function PhoneNumberInput(props: TextInputProps): VNode { type="tel" placeholder={props.placeholder} class={showError ? "input is-danger" : "input"} + onKeyPress={(e) => { + if (e.key === 'Enter' && props.onConfirm) { + props.onConfirm() + } + }} onInput={(e) => { setDirty(true); props.bind[1]((e.target as HTMLInputElement).value); diff --git a/packages/anastasis-webui/src/components/fields/TextInput.tsx b/packages/anastasis-webui/src/components/fields/TextInput.tsx index 4f417730c..efa95d84e 100644 --- a/packages/anastasis-webui/src/components/fields/TextInput.tsx +++ b/packages/anastasis-webui/src/components/fields/TextInput.tsx @@ -8,6 +8,7 @@ export interface TextInputProps { error?: string; placeholder?: string; tooltip?: string; + onConfirm?: () => void; bind: [string, (x: string) => void]; } @@ -37,6 +38,11 @@ export function TextInput(props: TextInputProps): VNode { disabled={props.disabled} placeholder={props.placeholder} class={showError ? "input is-danger" : "input"} + onKeyPress={(e) => { + if (e.key === 'Enter' && props.onConfirm) { + props.onConfirm() + } + }} onInput={(e) => { setDirty(true); props.bind[1]((e.target as HTMLInputElement).value); |