Skip to content

Commit

Permalink
update focus
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreCrb committed Feb 13, 2020
1 parent f71ee71 commit f35cf3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/components/inspector/controls/ChildrenControl.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef, useEffect } from 'react'
import React, { useRef, useEffect, KeyboardEvent } from 'react'
import { Input } from '@chakra-ui/core'
import FormControl from './FormControl'
import useDispatch from '../../../hooks/useDispatch'
Expand All @@ -13,9 +13,9 @@ const ChildrenControl: React.FC = () => {
const focusInput = useSelector(getInputTextFocused)
const { setValueFromEvent } = useForm()
const children = usePropsSelector('children')
const onKeyUp = (event: any) => {
if (event.keyCode === 13) {
dispatch.app.toggleInputText(false)
const onKeyUp = (event: KeyboardEvent) => {
if (event.keyCode === 13 && textInput.current) {
textInput.current.blur()
}
}
useEffect(() => {
Expand All @@ -37,6 +37,9 @@ const ChildrenControl: React.FC = () => {
onChange={setValueFromEvent}
ref={textInput}
onKeyUp={onKeyUp}
onBlur={() => {
dispatch.app.toggleInputText(false)
}}
/>
</FormControl>
)
Expand Down
3 changes: 0 additions & 3 deletions src/hooks/useInteractive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ export const useInteractive = (
event.preventDefault()
event.stopPropagation()
dispatch.components.select(component.id)
if (focusInput) {
dispatch.app.toggleInputText()
}
},
onDoubleClick: (event: MouseEvent) => {
event.preventDefault()
Expand Down

0 comments on commit f35cf3d

Please sign in to comment.