Commit 70e54699 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[inputWithEnter] add autoSave option

Otherwise, autoFocus triggered save action immediately, causing UI glitches.
parent 587430f2
......@@ -86,6 +86,7 @@ addNodeView p@{ dispatch, nodeType, nodeTypes } = R.createElement el p []
onEnter: \_ -> launchAff_ $ dispatch (AddNode name' nt')
, onValueChanged: \val -> setNodeName $ const val
, autoFocus: true
, autoSave: false
, className: "form-control"
, defaultValue: name'
, placeholder: name'
......
......@@ -364,6 +364,7 @@ searchInput p = R.createElement searchInputComponent p []
inputWithEnter { onEnter: onEnter valueRef setSearch
, onValueChanged: onValueChanged valueRef
, autoFocus: false
, autoSave: true
, className: "form-control"
, defaultValue: R.readRef valueRef
, placeholder: "Your query here"
......
......@@ -81,7 +81,8 @@ textInputBox p@{ boxName, boxAction, dispatch, isOpen: (true /\ setIsOpen) } = R
inputWithEnter {
onEnter: submit newName
, onValueChanged: setNewName <<< const
, autoFocus: false
, autoFocus: true
, autoSave: false
, className: "form-control"
, defaultValue: text
, placeholder: (boxName <> " Node")
......
......@@ -16,6 +16,7 @@ type Props a = (
, onValueChanged :: String -> Effect Unit
, autoFocus :: Boolean
, autoSave :: Boolean
, className :: String
, defaultValue :: String
, placeholder :: String
......@@ -29,8 +30,8 @@ inputWithEnter props = R.createElement inputWithEnterCpt props []
inputWithEnterCpt = R.hooksComponentWithModule thisModule "inputWithEnter" cpt
cpt props@{ onEnter, onValueChanged
, autoFocus, className, defaultValue, placeholder } _ = do
pure $ H.input { on: { blur: \_ -> onEnter unit
, autoFocus, autoSave, className, defaultValue, placeholder } _ = do
pure $ H.input { on: { blur: \_ -> if autoSave then onEnter unit else pure unit
, input: onInput
, keyPress: onKeyPress }
, autoFocus
......
......@@ -129,6 +129,7 @@ contactInfoItemCpt = R.hooksComponentWithModule thisModule "contactInfoItem" cpt
onEnter: onClick
, onValueChanged: R.setRef valueRef
, autoFocus: true
, autoSave: false
, className: "form-control"
, defaultValue: R.readRef valueRef
, placeholder
......
......@@ -310,6 +310,7 @@ renameableTextCpt = R.hooksComponentWithModule thisModule "renameableTextCpt" cp
onEnter: submit
, onValueChanged: setText <<< const
, autoFocus: false
, autoSave: false
, className: "form-control text"
, defaultValue: text
, placeholder: ""
......
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