diff options
author | 2023-02-06 09:19:56 +0100 | |
---|---|---|
committer | 2023-02-06 09:19:56 +0100 | |
commit | 47daddc10c291ec67320dd2485bffc498ea44bdf (patch) | |
tree | 530677541399c27cd292dfc0050a71273c35f098 /web/source/settings/lib/form/text.jsx | |
parent | [chore]: Bump codeberg.org/gruf/go-runners from 1.4.0 to 1.5.1 (#1428) (diff) | |
download | gotosocial-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/text.jsx')
-rw-r--r-- | web/source/settings/lib/form/text.jsx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/web/source/settings/lib/form/text.jsx b/web/source/settings/lib/form/text.jsx index d9a9ab28c..ce116f9ab 100644 --- a/web/source/settings/lib/form/text.jsx +++ b/web/source/settings/lib/form/text.jsx @@ -20,15 +20,16 @@ const React = require("react"); +const _default = ""; module.exports = function useTextInput({ name, Name }, { - defaultValue = "", + initialValue = _default, dontReset = false, validator, showValidation = true, initValidation } = {}) { - const [text, setText] = React.useState(defaultValue); + const [text, setText] = React.useState(initialValue); const textRef = React.useRef(null); const [validation, setValidation] = React.useState(initValidation ?? ""); @@ -48,7 +49,7 @@ module.exports = function useTextInput({ name, Name }, { function reset() { if (!dontReset) { - setText(defaultValue); + setText(initialValue); } } @@ -81,6 +82,7 @@ module.exports = function useTextInput({ name, Name }, { setter: setText, valid, validate: () => setValidation(validator(text)), - hasChanged: () => text != defaultValue + hasChanged: () => text != initialValue, + _default }); };
\ No newline at end of file |