-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Closed
Labels
Team:Kibana ManagementDev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t//Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t//enhancementNew value added to drive a business resultNew value added to drive a business result
Description
We have seen in several places the benefit of being able to change the defaultValue passed to the useForm and automatically trigger a form.reset() for the consumer.
This would allow the following data flow
const [formDefaultValue, setFormDefaultValue] = useState(someInitialDefaultValue);
const { form } = useForm({ defaultValue: formDefaultValue });
const onTypeChange = (type: string) => {
// Whenever the processor type changes, update the default value of the form
// that will reset the form
setFormDefaultValue(() => {
if (type === someInitialDefaultValue?.type) {
return someInitialDefaultValue;
}
// Only return the "type", the rest of the field will read the defautValue from their config.
return { type };
});
};
// JSX
<UseField path="type" onChange={onTypeChange} /> Metadata
Metadata
Assignees
Labels
Team:Kibana ManagementDev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t//Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more t//enhancementNew value added to drive a business resultNew value added to drive a business result