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
[Experimental] Product Filter: Price (Beta) block: Prevent invalid price range selection in Product Filter Price block #45403
Conversation
Hi @albarin, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
Test Results SummaryCommit SHA: a802d17
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
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.
Code looks good and tested well! Thanks for working on this PR! LGTM 🚢
// In some occasions the input element is updated with the incorrect value. | ||
// By using the element that triggered the event, we can ensure the correct value is used for the input. | ||
const element = getElement(); | ||
if ( type === 'min' ) { | ||
element.ref.value = currentMinPrice; | ||
} | ||
|
||
if ( type === 'max' ) { | ||
element.ref.value = currentMaxPrice; | ||
} |
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.
Nice solution!
) | ||
: maxPrice; | ||
|
||
// In some occasions the input element is updated with the incorrect value. |
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.
In my case, when the min and max price are equal, if I continue to move the max price to lower than the min price, the prices in the text inputs are correct, but the thumb doesn't return to the correct position.
…ice range selection in Product Filter Price block (#45403) * Prevent invalid price range selection in Product Filter Price block * Add changefile(s) from automation for the following project(s): woocommerce-blocks --------- Co-authored-by: github-actions <github-actions@github.com>
Changes proposed in this Pull Request:
This PR adds checks to prevent shoppers from using invalid price range selections, such as selecting a minimum price that is higher than the max price. It also uses the
getElement
method from the Interactivity API to get the element that triggered the update price event and force the correct value to be set to the input.Closes #45361.
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
/shop
).Changelog entry
Significance
Type
Message
Fix an issue where shoppers could select invalid price ranges in the Product Filter: Price (Beta) block
Comment