From 47daddc10c291ec67320dd2485bffc498ea44bdf Mon Sep 17 00:00:00 2001 From: f0x52 Date: Mon, 6 Feb 2023 09:19:56 +0100 Subject: [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 --- web/source/settings/lib/form/combo-box.jsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'web/source/settings/lib/form/combo-box.jsx') 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 -- cgit v1.2.3