Fix: Ensure VariantPicker initialization handles all fieldsets correctly#34
Open
iminiscript wants to merge 1 commit intoShopify:mainfrom
Open
Fix: Ensure VariantPicker initialization handles all fieldsets correctly#34iminiscript wants to merge 1 commit intoShopify:mainfrom
iminiscript wants to merge 1 commit intoShopify:mainfrom
Conversation
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.
This PR fixes a bug in the initialization logic of the VariantPicker component. The component's internal state for tracking selected variant indices (#checkedIndices) was not being properly set up for fieldsets that did not have an option pre-selected on initial page load.
This omission could lead to a runtime error (specifically, trying to access properties of undefined) inside the updateSelectedOption method when a user made their first selection in an uninitialized fieldset.
The fix ensures that an entry (an empty array []) is always created in this.#checkedIndices for every fieldset, guaranteeing the array structure is ready for the subsequent selection logic.
✅ What Was Fixed
The change was applied exclusively in the connectedCallback method:
Bug Fix: Inconsistent State Initialization
File: VariantPicker.js
Method:
connectedCallback()Change: Modified the logic to always push an array into this.#checkedIndices for every fieldset, even if no initial variant is checked