summaryrefslogtreecommitdiff
path: root/web/source/settings/lib/form/combo-box.jsx
diff options
context:
space:
mode:
authorLibravatar f0x52 <f0x@cthu.lu>2023-02-06 09:19:56 +0100
committerLibravatar GitHub <noreply@github.com>2023-02-06 09:19:56 +0100
commit47daddc10c291ec67320dd2485bffc498ea44bdf (patch)
tree530677541399c27cd292dfc0050a71273c35f098 /web/source/settings/lib/form/combo-box.jsx
parent[chore]: Bump codeberg.org/gruf/go-runners from 1.4.0 to 1.5.1 (#1428) (diff)
downloadgotosocial-47daddc10c291ec67320dd2485bffc498ea44bdf.tar.xz
[chore/frogend] Restructure form data default values / update from Query data (#1422)
* eslint: set console use to error to catch debug littering in CI * remove debug logging * some form field restructuring, fixes submitted updates not being reflected * more form field restructuring * remove debug logger * simplify field updates * fix react state set during render when submitting import file * className instead of class * show Select hints again
Diffstat (limited to 'web/source/settings/lib/form/combo-box.jsx')
-rw-r--r--web/source/settings/lib/form/combo-box.jsx13
1 files changed, 8 insertions, 5 deletions
diff --git a/web/source/settings/lib/form/combo-box.jsx b/web/source/settings/lib/form/combo-box.jsx
index 3e8cea44a..ce799f430 100644
--- a/web/source/settings/lib/form/combo-box.jsx
+++ b/web/source/settings/lib/form/combo-box.jsx
@@ -22,17 +22,18 @@ const React = require("react");
const { useComboboxState } = require("ariakit/combobox");
-module.exports = function useComboBoxInput({ name, Name }, { defaultValue } = {}) {
+const _default = "";
+module.exports = function useComboBoxInput({ name, Name }, { initialValue = _default }) {
const [isNew, setIsNew] = React.useState(false);
const state = useComboboxState({
- defaultValue,
+ defaultValue: initialValue,
gutter: 0,
sameWidth: true
});
function reset() {
- state.setValue("");
+ state.setValue(initialValue);
}
return Object.assign([
@@ -48,9 +49,11 @@ module.exports = function useComboBoxInput({ name, Name }, { defaultValue } = {}
name,
state,
value: state.value,
- hasChanged: () => state.value != defaultValue,
+ setter: (val) => state.setValue(val),
+ hasChanged: () => state.value != initialValue,
isNew,
setIsNew,
- reset
+ reset,
+ _default
});
}; \ No newline at end of file