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:
@ -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
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user