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(bctheme): BCTHEME-20 Stencil Themes - Non-required options do not… #1714
fix(bctheme): BCTHEME-20 Stencil Themes - Non-required options do not… #1714
Conversation
… have a 'none' choice on the storefront
Autotagging @bigcommerce/storefront-team @davidchin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
|
||
try { | ||
for (const [key, val] of formData) { | ||
if (!(val instanceof File) || val.name || val.size) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why loop through the same form data again. Can we just merge this check into the above method definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is util function which can be used by its own because I believe sending empty values not only issue for product options fields
* @returns FormData object | ||
*/ | ||
export const filterEmptyValuesFromForm = formData => { | ||
const res = new FormData(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to create a new formData ? since the incoming formData is already of the type FormData
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pure function which makes result of executing predictable and easy testable. I have faced some issues with changing form data by link so decided to make it in this way
… have a 'none' choice on the storefront
What?
Historically, when product options were set to not required a shopper would have the ability to select 'none' on the option. Stencil themes not provide this choice, so if a shopper selects an option that isn't required, they do not have the ability to de-select it by choosing 'none'. This can be frustrating for shoppers, especially when there are price change rules attached to the non-required option.
Tickets / Documentation
https://jira.bigcommerce.com/browse/BCTHEME-20
Screenshots (if appropriate)
ping @yurytut1993 @golcinho @junedkazi