Fix the issue where TextGeneration
component does not correctly clear input data.
#12351
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #11849
This PR is a resubmission as requested, as part of the now-closed #11850 .
Fixed
TextGeneration
component does not correctly clear input dataTextGeneration
component did not properly reset references when clearing the form. This issue caused old form values to be automatically filled in upon re-entering data. Now, the form references are correctly reset after clearing, ensuring that new input data is not affected by previous values.Modification Details
This pull request includes changes to the
web/app/components/share/text-generation/index.tsx
file to improve the handling of state updates and references. The most important changes are the addition of theuseCallback
hook and the refactoring of theinputs
state management.Improvements to state management:
useCallback
to memoize thesetInputs
function, ensuring that it does not get recreated on each render. (web/app/components/share/text-generation/index.tsx
)inputs
state management by introducingdoSetInputs
andinputsRef
to keep the state and its reference in sync. (web/app/components/share/text-generation/index.tsx
)Checklist
Important
Please review the checklist below before submitting your pull request.
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint gods