-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(web): Use initial Workflow Preferences state to determine override state #6591
fix(web): Use initial Workflow Preferences state to determine override state #6591
Conversation
|
||
useEffect(() => { | ||
if (workflowUserPreferences !== undefined) { | ||
if (workflowUserPreferences !== undefined && getValues('preferences') === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the form state to retain context of the form values, only setting the form values if it wasn't set already. This prevents the Preferences component state from being reset to null
when the API fetch occurs on component render.
@@ -47,7 +47,7 @@ export const WorkflowSubscriptionPreferences: FC<WorkflowSubscriptionPreferences | |||
updateWorkflowPreferences, | |||
arePreferencesDisabled, | |||
}) => { | |||
const [isOverridingPreferences, setIsOverridingPreferences] = useState(false); | |||
const [isOverridingPreferences, setIsOverridingPreferences] = useState(workflowUserPreferences !== null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix to ensure the initial state for preference override toggle is correct to ensure the useEffect condition that resets the form value isn't fired on initial render.
…ot-saved-immediately
What changed? Why was the change needed?
Screenshots
https://www.loom.com/share/8b5aa3e3f8a749f48ff6b0d4425bb48d?sid=237293f4-746d-4cda-a46c-0350b62456db
Expand for optional sections
Related enterprise PR
Special notes for your reviewer