fix: check form data after blur
This commit is contained in:
@@ -6,6 +6,7 @@ interface HintInputProps {
|
||||
value: string;
|
||||
label?: string;
|
||||
onChange: (value: string) => void;
|
||||
onBlur?: (e: any) => void;
|
||||
placeholder?: string;
|
||||
sourceOptions?: Global.HintOptions[];
|
||||
}
|
||||
@@ -13,7 +14,7 @@ interface HintInputProps {
|
||||
const matchReg = /[^=]+=[^=]*$/;
|
||||
|
||||
const HintInput: React.FC<HintInputProps> = (props) => {
|
||||
const { value, label, onChange, sourceOptions } = props;
|
||||
const { value, label, onChange, onBlur, sourceOptions } = props;
|
||||
const cursorPosRef = React.useRef(0);
|
||||
const contextBeforeCursorRef = React.useRef('');
|
||||
const [options, setOptions] = React.useState<
|
||||
@@ -89,6 +90,7 @@ const HintInput: React.FC<HintInputProps> = (props) => {
|
||||
onInput={handleInput}
|
||||
onSelect={handleOnSelect}
|
||||
onFocus={getContextBeforeCursor}
|
||||
onBlur={onBlur}
|
||||
label={label}
|
||||
options={options}
|
||||
style={{ width: '100%' }}
|
||||
|
||||
@@ -15,6 +15,7 @@ interface ListInputProps {
|
||||
placeholder?: string;
|
||||
labelExtra?: React.ReactNode;
|
||||
onChange: (data: string[]) => void;
|
||||
onBlur?: (e: any, index: number) => void;
|
||||
}
|
||||
|
||||
const ListInput: React.FC<ListInputProps> = (props) => {
|
||||
@@ -24,6 +25,7 @@ const ListInput: React.FC<ListInputProps> = (props) => {
|
||||
label,
|
||||
description,
|
||||
onChange,
|
||||
onBlur,
|
||||
btnText,
|
||||
options,
|
||||
labelExtra
|
||||
@@ -89,6 +91,7 @@ const ListInput: React.FC<ListInputProps> = (props) => {
|
||||
options={options}
|
||||
key={item.uid}
|
||||
value={item.value}
|
||||
onBlur={(e) => onBlur?.(e, index)}
|
||||
onRemove={() => handleOnRemove(index)}
|
||||
onChange={(val) => handleOnChange(val, index)}
|
||||
/>
|
||||
|
||||
@@ -8,6 +8,7 @@ import './styles/list-item.less';
|
||||
interface LabelItemProps {
|
||||
onRemove: () => void;
|
||||
onChange: (value: string) => void;
|
||||
onBlur?: (e: any) => void;
|
||||
value: string;
|
||||
label?: string;
|
||||
placeholder?: string;
|
||||
@@ -15,7 +16,7 @@ interface LabelItemProps {
|
||||
}
|
||||
|
||||
const ListItem: React.FC<LabelItemProps> = (props) => {
|
||||
const { onRemove, onChange, label, value, options } = props;
|
||||
const { onRemove, onChange, onBlur, label, value, options } = props;
|
||||
|
||||
const handleOnChange = (value: any) => {
|
||||
onChange(value);
|
||||
@@ -26,6 +27,7 @@ const ListItem: React.FC<LabelItemProps> = (props) => {
|
||||
<HintInput
|
||||
value={value}
|
||||
onChange={handleOnChange}
|
||||
onBlur={onBlur}
|
||||
label={label}
|
||||
sourceOptions={options}
|
||||
placeholder={props.placeholder}
|
||||
|
||||
Reference in New Issue
Block a user