-
Notifications
You must be signed in to change notification settings - Fork 77
Revert "Fix datamapper button not appearing" #1895
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 | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,9 +33,7 @@ export const VariableForm = (props: FormProps) => { | |||||||||||||||||||
| }, [props.formFields]); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const handleOnTypeChange = (type: string | CompletionItem) => { | ||||||||||||||||||||
| Promise.resolve(handleSelectedTypeChange?.(type)).catch((error) => { | ||||||||||||||||||||
| console.error("Error in handleSelectedTypeChange", error); | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| handleSelectedTypeChange(type); | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
Comment on lines
35
to
37
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. Missing null check after removing optional chaining. The While 🛡️ Proposed fix to restore defensive check const handleOnTypeChange = (type: string | CompletionItem) => {
- handleSelectedTypeChange(type);
+ handleSelectedTypeChange?.(type);
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| return ( | ||||||||||||||||||||
| <> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -522,7 +522,7 @@ export const FormGenerator = forwardRef<FormExpressionEditorRef, FormProps>(func | |||||||||
| const updatedField = { ...field }; | ||||||||||
|
|
||||||||||
| const isRepeatableList = field.types?.length === 1 && getPrimaryInputType(field.types)?.fieldType === "REPEATABLE_LIST"; | ||||||||||
| const selectedInputType = isRepeatableList ? getPrimaryInputType(field.types) : field.types?.find(t => t.selected); | ||||||||||
| const selectedInputType = isRepeatableList? getPrimaryInputType(field.types) : field.types?.find(t => t.selected); | ||||||||||
|
|
||||||||||
| const nodeProperties = nodeWithDiagnostics?.properties as any; | ||||||||||
| let propertyDiagnostics: any = nodeProperties?.[field.key]?.diagnostics?.diagnostics; | ||||||||||
|
|
@@ -922,7 +922,7 @@ export const FormGenerator = forwardRef<FormExpressionEditorRef, FormProps>(func | |||||||||
|
|
||||||||||
| return Object.values(nodeProperties).some((property) => { | ||||||||||
| let diagnostics: DiagnosticMessage[] = []; | ||||||||||
| if (property?.types?.length === 1 && getPrimaryInputType(property.types)?.fieldType === "REPEATABLE_LIST") { | ||||||||||
| if ( property?.types?.length === 1 && getPrimaryInputType(property.types)?.fieldType === "REPEATABLE_LIST") { | ||||||||||
| // For repeatable list, check diagnostics for each element in the list | ||||||||||
| const valueDiagnostics = (property.value as any[])?.map((val) => val?.diagnostics?.diagnostics ?? []).flat() ?? []; | ||||||||||
| diagnostics = [...diagnostics, ...valueDiagnostics]; | ||||||||||
|
|
@@ -1399,24 +1399,13 @@ export const FormGenerator = forwardRef<FormExpressionEditorRef, FormProps>(func | |||||||||
| /** | ||||||||||
| * Handles type selection from completion items (used in type editor) | ||||||||||
| */ | ||||||||||
| const handleSelectedTypeChange = async (type: CompletionItem | string) => { | ||||||||||
| try { | ||||||||||
| if (typeof type === "string") { | ||||||||||
| await handleSelectedTypeByName(type); | ||||||||||
| return; | ||||||||||
| } | ||||||||||
| else { | ||||||||||
| // If the type is a Completion item, then it can be found in the reference types. | ||||||||||
| // Which cannot be an imported type. | ||||||||||
| importsCodedataRef.current = null; | ||||||||||
| await fetchVisualizableFields(fileName, (type as CompletionItem).label); | ||||||||||
| } | ||||||||||
| setSelectedType(type); | ||||||||||
| updateRecordTypeFields(type); | ||||||||||
| } | ||||||||||
| catch (error) { | ||||||||||
| console.error("Error handling selected type change", error); | ||||||||||
| const handleSelectedTypeChange = (type: CompletionItem | string) => { | ||||||||||
| if (typeof type === "string") { | ||||||||||
| handleSelectedTypeByName(type); | ||||||||||
|
||||||||||
| handleSelectedTypeByName(type); | |
| void handleSelectedTypeByName(type).catch((error) => { | |
| console.error("Failed to handle selected type by name:", error); | |
| }); |
Copilot
AI
Apr 3, 2026
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.
When typeName is empty/invalid or the type can’t be found, this function now returns without updating/clearing visualizableField (and without resetting importsCodedataRef). Since visualizableField is used to decide whether the Data Mapper button is enabled and to provide default values, it can become stale after a type is cleared/changed. Consider explicitly resetting visualizableField (and importsCodedataRef.current) on these early-return paths, or triggering a refresh that results in a cleared state.
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.
handleSelectedTypeChangeis optional onFormProps, but it’s being called unconditionally here. If a caller doesn’t provide it, this will throw at runtime when the user changes the type. Guard with optional chaining (or a default no-op) similar to the previous implementation, and keep error handling if the callback can fail.