-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix: Enable save button for provider dropdown and checkbox changes #7113
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -219,17 +219,17 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t | |||||||||||||||||||||
| }, []) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const setApiConfigurationField = useCallback( | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding JSDoc documentation for this function to explain the purpose of the
Suggested change
|
||||||||||||||||||||||
| <K extends keyof ProviderSettings>(field: K, value: ProviderSettings[K]) => { | ||||||||||||||||||||||
| <K extends keyof ProviderSettings>(field: K, value: ProviderSettings[K], isUserAction: boolean = true) => { | ||||||||||||||||||||||
| setCachedState((prevState) => { | ||||||||||||||||||||||
| if (prevState.apiConfiguration?.[field] === value) { | ||||||||||||||||||||||
| return prevState | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const previousValue = prevState.apiConfiguration?.[field] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Don't treat initial sync from undefined to a defined value as a user change | ||||||||||||||||||||||
| // This prevents the dirty state when the component initializes and auto-syncs the model ID | ||||||||||||||||||||||
| const isInitialSync = previousValue === undefined && value !== undefined | ||||||||||||||||||||||
| // Only skip change detection for automatic initialization (not user actions) | ||||||||||||||||||||||
| // This prevents the dirty state when the component initializes and auto-syncs values | ||||||||||||||||||||||
| const isInitialSync = !isUserAction && previousValue === undefined && value !== undefined | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic here is correct, but consider adding a comment to explain why we skip change detection for automatic initialization. This would help future maintainers understand the pattern. |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (!isInitialSync) { | ||||||||||||||||||||||
| setChangeDetected(true) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
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.
Good use of the comment here to clarify that this is automatic initialization! This pattern makes the intent very clear.