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 [] ...@@ -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"
......
...@@ -81,7 +81,8 @@ textInputBox p@{ boxName, boxAction, dispatch, isOpen: (true /\ setIsOpen) } = R ...@@ -81,7 +81,8 @@ textInputBox p@{ boxName, boxAction, dispatch, isOpen: (true /\ setIsOpen) } = R
inputWithEnter { inputWithEnter {
onEnter: submit newName onEnter: submit newName
, onValueChanged: setNewName <<< const , onValueChanged: setNewName <<< const
, autoFocus: false , autoFocus: true
, 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
......
...@@ -125,15 +125,16 @@ contactInfoItemCpt = R.hooksComponentWithModule thisModule "contactInfoItem" cpt ...@@ -125,15 +125,16 @@ contactInfoItemCpt = R.hooksComponentWithModule thisModule "contactInfoItem" cpt
onClick _ = setIsEditing $ const true onClick _ = setIsEditing $ const true
item (true /\ setIsEditing) valueRef = item (true /\ setIsEditing) valueRef =
H.span {} [ H.span {} [
inputWithEnter { inputWithEnter {
onEnter: onClick onEnter: onClick
, onValueChanged: R.setRef valueRef , onValueChanged: R.setRef valueRef
, autoFocus: true , autoFocus: true
, className: "form-control" , autoSave: false
, defaultValue: R.readRef valueRef , className: "form-control"
, placeholder , defaultValue: R.readRef valueRef
, type: "text" , placeholder
} , type: "text"
}
, H.span { className: "fa fa-floppy-o" , H.span { className: "fa fa-floppy-o"
, on: {click: onClick} } [] , on: {click: onClick} } []
] ]
......
...@@ -310,6 +310,7 @@ renameableTextCpt = R.hooksComponentWithModule thisModule "renameableTextCpt" cp ...@@ -310,6 +310,7 @@ renameableTextCpt = R.hooksComponentWithModule thisModule "renameableTextCpt" cp
onEnter: submit onEnter: submit
, onValueChanged: setText <<< const , onValueChanged: setText <<< const
, autoFocus: false , autoFocus: false
, autoSave: false
, className: "form-control text" , className: "form-control text"
, defaultValue: text , defaultValue: text
, placeholder: "" , 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