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