Skip to content

Commit

Permalink
🐛 (editor) Flush code editor value when closing
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 27, 2023
1 parent 680e967 commit d57fb47
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/builder/src/components/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
useColorModeValue,
useDisclosure,
} from '@chakra-ui/react'
import { useRef, useState } from 'react'
import { useEffect, useRef, useState } from 'react'
import { useDebouncedCallback } from 'use-debounce'
import { VariablesButton } from '@/features/variables'
import { Variable } from 'models'
Expand Down Expand Up @@ -70,6 +70,13 @@ export const CodeEditor = ({
setCarretPosition(codeEditor.current?.state?.selection.main.head ?? 0)
}

useEffect(
() => () => {
setValue.flush()
},
[setValue]
)

return (
<HStack
align="flex-end"
Expand Down

0 comments on commit d57fb47

Please sign in to comment.