fix(VE-6191): clear field schema map on variant change#432
Merged
faraazb merged 2 commits intodevelop_v3from May 6, 2025
Merged
fix(VE-6191): clear field schema map on variant change#432faraazb merged 2 commits intodevelop_v3from
faraazb merged 2 commits intodevelop_v3from
Conversation
Clear field schema map on variant change as it contains a field - isUnlinkedVariant which depends on the current selected variant for its value
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue by ensuring that the field schema map is fully cleared when the variant changes, preventing stale field state from affecting the UI.
- Clears both fieldSchema and fieldSchemaPromise in FieldSchemaMap.
- Updates the useVariantFieldsPostMessageEvent event handler to call FieldSchemaMap.clear().
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/visualBuilder/utils/fieldSchemaMap.ts | Updates the clear() method to reset both fieldSchema and fieldSchemaPromise. |
| src/visualBuilder/eventManager/useVariantsPostMessageEvent.ts | Adds a call to FieldSchemaMap.clear() upon variant change to clear cached fields. |
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
Contributor
hiteshshetty-dev
left a comment
There was a problem hiding this comment.
Let's add test cases
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where the field schema cache is not fully cleared when the variant changes, which can lead to incorrect field values.
- Clear the field schema promise map in the FieldSchemaMap.clear() method.
- Add a new test to verify that the promise map is cleared.
- Export several functions and call FieldSchemaMap.clear() in the variant post message event handler.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/visualBuilder/utils/fieldSchemaMap.ts | Updated clear method to reset both field schema and promise map |
| src/visualBuilder/utils/test/fieldSchemaMap.test.ts | Added test to verify the clearing of the promise map |
| src/visualBuilder/eventManager/useVariantsPostMessageEvent.ts | Exported several functions and added a call to clear the field schema cache on variant change |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Clear field schema map on variant change as it contains a field - isUnlinkedVariant which depends on the current selected variant for its value.
The "get-variant-id" message is received from "Visual Builder" whenever the variant is changed.