Skip to content

Commit

Permalink
feat: clear active field on component unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
karrui committed Jan 14, 2022
1 parent 02688bb commit d440555
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions frontend/src/features/admin-form-builder/BuilderContent.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { useEffect } from 'react'
import { Flex, Stack } from '@chakra-ui/react'

import { useAdminForm } from '~features/admin-form/common/queries'

import { FieldRowContainer } from './FieldRow/FieldRowContainer'
import { clearActiveFieldSelector, useEditFieldStore } from './editFieldStore'

export const BuilderContent = (): JSX.Element => {
const clearActiveField = useEditFieldStore(clearActiveFieldSelector)

useEffect(() => {
// Clear field on component unmount.
return () => clearActiveField()
}, [clearActiveField])

return (
<Flex flex={1} bg="neutral.200">
<Flex
Expand Down

0 comments on commit d440555

Please sign in to comment.