Skip to content
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

Fix duplicate IDs occurrence in product options in certain situations #1223

Closed
wants to merge 39 commits into from
Closed

Fix duplicate IDs occurrence in product options in certain situations #1223

wants to merge 39 commits into from

Conversation

flair-duncan
Copy link
Contributor

What?

In certain circumstances, product option elements end up with the same ID causing a clash, stopping some options being selected.

Each option component has been given a descriptive ID to prevent the clash. As the add to cart action relies on the name attribute, this does not interfere with the cart system.

Screenshots

Video of issue before changes

Video after changes

@bigbot
Copy link

bigbot commented May 2, 2018

Autotagging @bigcommerce/storefront-team @davidchin

@flair-duncan
Copy link
Contributor Author

@junedkazi sorry, I messed up my squash as there were a couple more commits to the master while I was working on it, it was quicker to do another PR.

Copy link
Contributor

@junedkazi junedkazi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @flair-duncan Code changes LGTM 👍. We will need to do some testing internally before we merge this one.

@bookernath
Copy link
Contributor

bookernath commented May 3, 2018

@flair-duncan do you have an example of duplicate IDs you can show, or some replication steps to get to such a state? This might be something we want to fix on the backend...

@flair-duncan
Copy link
Contributor Author

flair-duncan commented May 3, 2018

@bookernath we noticed this occurring on our own theme, and traced it back to the option components in Cornerstone. If you look at our theme store demo site on this page you can replicate the ID clash by clicking the color swatches.

Clicking the black swatch will select the "Chest Size" option. Both options have a duplicate ID, in this case id="attribute_41".

I've used this same data with Cornerstone and the same thing happens.

If you want me to create an API key so you can use that store data, let me know. 👍

@mattolson
Copy link
Contributor

@Ubersmake Can you test this?

@junedkazi
Copy link
Contributor

@flair-duncan sorry for the delay can you rebase this PR & move the change log into the new draft section please.

@junedkazi
Copy link
Contributor

@flair-duncan looks like the rebase has gone wrong.

@flair-duncan
Copy link
Contributor Author

@junedkazi hmm, I'll sort it out over the weekend...

@junedkazi
Copy link
Contributor

@flair-duncan this looks good to me. Can you please squash your commits into a single one please.

PeteyRev and others added 20 commits June 5, 2018 11:00
* Modernizr is a blocking script that has very little benefit for us. Removing this
  script improves page responsiveness.
* We used Modernizr via the css classes `csscolumns`, `flexbox`, `objectfit`, and `js`.
* The `csscolumns` class was used for productMasonry for older browsers, but since then
  all of our supported browsers support css columns. There is one small problem with
  Firefox: it does not support break-inside, but it does support page-break-inside,
  which does the same thing. See https://caniuse.com/#feat=multicolumn
* The `flexbox` class is unused
* The `objectfit` class is used by carousel. Reimplmented without using Modernizer.
  The previous implmentation put a background image on the wrapper div and then
  hid it if object-fit is supported. The new implementation does not put the background
  image on the wrapper div by default, but instead assumes that your browser supports
  object-fit (all ours do except for IE). For IE, we use javascript to copy the image
  source from the image tag to the background image of the wrapper div and then hide
  the image.
* The `js` class is used for a few things in css, so mimic this behavior with a simple
  inline script.
* Add wrapper div for hero carousel that has the appropriate height
  for the image to be displayed after lazy loading.
* This improves frontend performance because the browser will be less
  likely to load images below the fold immediately.
* Add dns prefetch & preconnect to core resources that we
  know we will need -- fonts, cdn, jirafe, etc
* Upgrade to webpack 4
* Clean up stencil bootstrap
* Simplify interface for PageManager and get rid of async library dependency
* Get rid of html5-history-api library dependency (no longer needed)
* Get rid of fastclick library dependency (no longer needed)
* Upgrade several babel dependencies
* Separate webpack config into common, dev, prod, and add npm scripts to build
* Get rid of minifications in babel loader, instead rely on webpack
* Get rid of LoaderOptionsPlugin
* Get rid of CommonsChunkPlugin (webpack 4 will automaticaly do this for prod)
* Use svg-injector to fetch the svg icon sprite rather than
  embed it directly on the page. This improves frontend performance
  because the icons will be cached after the first request and
  we reduce the page weight by about 28kb.
* Move location of generated svg so it is retrievable by the frontend
  through the CDN.
* Update svgstore grunt task
* Reduce the default number of featured, new, and bestselling
  products on the home page.
* These can always be updated in Theme Editor, but the defaults
  don't need to be so high.
* Use laziest possible setting for images
* Use `resourceHints` helper from paper 2.0.8, which looks up
  configured cdn and font providers.
David Payne and others added 19 commits June 5, 2018 11:00
    setting for skus. We were not properly switching back and forth
    between skus that were above and below their own respective
    threshholds.
This reverts commit c3acff8, reversing
changes made to 1acb31e.
In certain circumstances elements end up with the same ID causing a clash, stopping some options being selected

Changes as requested on PR#1215

Change _ to - in input-checkbox component

Open correct product page tabs when URL refers to them

Comment and clean up product-details.js

Changes as requested on PR#1215

Change _ to - in input-checkbox component

Update product-details.js

Fix duplicate IDs occurrence in product options in certain situations

Fixing
@flair-duncan
Copy link
Contributor Author

@junedkazi I've got absolutely no idea why it's just done that, I successfully rebased and squashed at my end... I'm just going to create a clean PR for you to save time. Sorry 😞

@junedkazi
Copy link
Contributor

@flair-duncan did u get a chance to look into this issue ?

@junedkazi
Copy link
Contributor

closed in favor of #1261

@junedkazi junedkazi closed this Jun 11, 2018
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.

None yet

10 participants