mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-24 18:02:47 +08:00
feat: support enter to create workspace
This commit is contained in:
@@ -11,6 +11,7 @@ type inputProps = {
|
||||
onChange?: (value: string) => void;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
onBlur?: (e: any) => void;
|
||||
onKeyDown?: (e: any) => void;
|
||||
};
|
||||
|
||||
export const Input = (props: inputProps) => {
|
||||
@@ -23,6 +24,7 @@ export const Input = (props: inputProps) => {
|
||||
width = 260,
|
||||
onChange,
|
||||
onBlur,
|
||||
onKeyDown,
|
||||
} = props;
|
||||
const [value, setValue] = useState<string>(valueProp || '');
|
||||
const handleChange: InputHTMLAttributes<HTMLInputElement>['onChange'] = e => {
|
||||
@@ -37,6 +39,10 @@ export const Input = (props: inputProps) => {
|
||||
const handleBlur: InputHTMLAttributes<HTMLInputElement>['onBlur'] = e => {
|
||||
onBlur && onBlur(e);
|
||||
};
|
||||
const handleKeyDown: InputHTMLAttributes<HTMLInputElement>['onKeyDown'] =
|
||||
e => {
|
||||
onKeyDown && onKeyDown(e);
|
||||
};
|
||||
useEffect(() => {
|
||||
setValue(valueProp || '');
|
||||
}, [valueProp]);
|
||||
@@ -50,6 +56,7 @@ export const Input = (props: inputProps) => {
|
||||
minLength={minLength}
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
onKeyDown={handleKeyDown}
|
||||
></StyledInput>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user