Commit e6cf756a authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[inputWithEnter] add autoSave option

Otherwise, autoFocus triggered save action immediately, causing UI glitches.
parent d1318617
......@@ -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"
......
......@@ -83,6 +83,7 @@ textInputBox p@{ boxName, boxAction, dispatch, isOpen: (true /\ setIsOpen) } = R
onEnter: submit renameNodeNameRef
, onValueChanged: R.setRef renameNodeNameRef
, autoFocus: false
, 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
......
......@@ -127,6 +127,7 @@ contactInfoItemCpt = R.hooksComponentWithModule thisModule "contactInfoItem" cpt
H.div { className: "input-group col-sm-6" } [
inputWithEnter {
autoFocus: true
, autoSave: false
, className: "form-control"
, defaultValue: R.readRef valueRef
, onEnter: onClick
......
......@@ -314,6 +314,7 @@ renameableTextCpt = R.hooksComponentWithModule thisModule "renameableTextCpt" cp
pure $ H.div { className: "input-group" } [
inputWithEnter {
autoFocus: false
, autoSave: false
, className: "form-control text"
, defaultValue: text
, onEnter: submit
......
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