forked from premieroctet/openchakra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove children autofocus & add Text Input focus
- Loading branch information
Showing
4 changed files
with
33 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,36 @@ | ||
import React from "react"; | ||
import { Input } from "@chakra-ui/core"; | ||
import FormControl from "./FormControl"; | ||
import { useForm } from "../../../hooks/useForm"; | ||
import usePropsSelector from "../../../hooks/usePropsSelector"; | ||
import React, { useRef, useEffect } from 'react' | ||
import { Input } from '@chakra-ui/core' | ||
import FormControl from './FormControl' | ||
import { useForm } from '../../../hooks/useForm' | ||
import usePropsSelector from '../../../hooks/usePropsSelector' | ||
import { useSelector } from 'react-redux' | ||
import { getShowInputText } from '../../../core/selectors/app' | ||
|
||
const ChildrenControl: React.FC = () => { | ||
const { setValueFromEvent } = useForm(); | ||
const children = usePropsSelector("children"); | ||
const textInput = useRef<HTMLInputElement>(null) | ||
const focusInput = useSelector(getShowInputText) | ||
const { setValueFromEvent } = useForm() | ||
const children = usePropsSelector('children') | ||
|
||
useEffect(() => { | ||
if (focusInput && textInput.current) { | ||
textInput.current.focus() | ||
} | ||
}, [focusInput]) | ||
|
||
return ( | ||
<FormControl htmlFor="children" label="Text"> | ||
<Input | ||
id="children" | ||
name="children" | ||
autoFocus | ||
size="sm" | ||
value={children || ""} | ||
value={children || ''} | ||
type="text" | ||
onChange={setValueFromEvent} | ||
ref={textInput} | ||
/> | ||
</FormControl> | ||
); | ||
}; | ||
) | ||
} | ||
|
||
export default ChildrenControl; | ||
export default ChildrenControl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters