Optimize shopping cart page to avoid flash of unavailable sizes(#40455)#40458
Open
Madhavendrasinh-Vaghela wants to merge 1 commit intoampproject:mainfrom
Open
Optimize shopping cart page to avoid flash of unavailable sizes(#40455)#40458Madhavendrasinh-Vaghela wants to merge 1 commit intoampproject:mainfrom
Madhavendrasinh-Vaghela wants to merge 1 commit intoampproject: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.
Fixes #40455
Description
This PR fixes a UI issue in the e-commerce example where all size options would momentarily flash as "unavailable" (crossed out) when switching between shirt colors.
Motivation
When a user selects a different color, the application fetches the size data for that color asynchronously. During this network request, the
sizesobject isundefined. The previous logic!shirts[selected.id].sizes['SIZE']evaluated totrueduring this loading and undefined state, causing the UI to incorrectly mark all sizes as unavailable.Changes
Updated the
[class]binding logic for all size options inexamples/bind/ecommerce.amp.html.
shirts[selected.id].sizes && ...to ensure thesizesdata exists before determining if a specific size is unavailable.Verification
1.Open
examples/bind/ecommerce.amp.html .
Select a different color (e.g., "Brown").
Observe that size options remain in their neutral state during the fetch and update correctly once data is loaded, without flashing the "unavailable" style.