Commit 004cab75 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[CodeEditor] fix CodeType changing triggers

parent bc9246a4
......@@ -192,23 +192,16 @@ toolbar p = R.createElement toolbarCpt p []
toolbarCpt :: R.Component ToolbarProps
toolbarCpt = R.hooksComponent "G.C.CE.toolbar" cpt
where
cpt props@{controls: {codeType, error, viewType}} _ = do
cpt {controls: {codeS, codeType, error, viewType}, onChange} _ = do
pure $
H.div { className: "row toolbar" } [
codeTypeSelector {
codeType
, onChange: onChangeCodeType props
, onChange: \newCodeType -> onChange newCodeType (fst codeS)
}
, viewTypeSelector {state: viewType}
]
-- Handle rerendering of preview when viewType changed
onChangeCodeType :: forall e. Record ToolbarProps -> e -> Effect Unit
onChangeCodeType {controls, onChange} _ = do
onChange (fst controls.codeType) code
where
code = fst controls.codeS
type ErrorComponentProps =
(
......
......@@ -78,7 +78,7 @@ corpusLayoutViewCpt = R.hooksComponent "G.C.N.C.corpusLayoutView" cpt
fieldsS <- R.useState' fieldsWithIndex
fieldsRef <- R.useRef fields
-- handle props change of fields
-- handle change of props-derived state
R.useEffect1' fields $ do
if R.readRef fieldsRef == fields then
pure unit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment