mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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
This commit is contained in:
@ -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
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user