Skip to content

Fix: Dispatch change event when updating variant ID input#54

Open
tobiasdalhof wants to merge 1 commit intoShopify:mainfrom
tobiasdalhof:fix/dispatch-variant-change-event
Open

Fix: Dispatch change event when updating variant ID input#54
tobiasdalhof wants to merge 1 commit intoShopify:mainfrom
tobiasdalhof:fix/dispatch-variant-change-event

Conversation

@tobiasdalhof
Copy link

@tobiasdalhof tobiasdalhof commented Mar 3, 2026

Problem

The variant ID is updated programmatically, which does not trigger native input or change events. Although this input is hidden, it is the required name="id" field for the Shopify Add to Cart form.

Many Shopify apps use this specific input as their primary source of truth because it is the most reliable way to identify the selected variant across different themes. Because the field remains "silent" during scripted updates, these apps cannot detect variant changes, causing their state or widgets to fall out of sync with the product page.

Solution

Manually dispatch a change event with { bubbles: true } immediately after the value is updated. This ensures the event propagates up the DOM, allowing both the theme and third-party apps to respond correctly.


I am aware the README states that PRs are not currently accepted. I am submitting this as a reference to address a widespread compatibility issue. I hope this can be considered for a future internal update to improve the theme's interoperability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant