adobe / aem-core-cif-components

A set of configurations and components to get you started with AEM Commerce development
Apache License 2.0
103 stars 80 forks source link

Product List Sorting Options Not Working As Expected #883

Open brandonmaynard opened 2 years ago

brandonmaynard commented 2 years ago

Expected Behaviour

When adding both ACS & DESC sorting for the same key, the UI select should have each option with different values and only one 'selected' at a time.

Actual Behaviour

When adding both ACS & DESC for the same key, the UI has each option, but they have the same value and both are selected

Reproduce Scenario (including but not limited to)

Modify the ProductListImpl to add price with sorting options with ASC & DESC for the same key. searchOptions.addSorterKey("price", "Price (low to high)", Sorter.Order.ASC); searchOptions.addSorterKey("price", "Price (high to low)", Sorter.Order.DESC);

On the UI, the sorting dropdown has both Price (low to high) and Price (high to low) options, but they are both selected and they both have the same value (with sort_order=asc).

Steps to Reproduce

See above

Platform and Version

AEMaaCS - aem-sdk-quickstart-2022.2.6433.20220223T194056Z-220100.jar

Sample Code that illustrates the problem

On https://github.com/adobe/aem-core-cif-components/blob/master/bundles/core/src/main/java/com/adobe/cq/commerce/core/search/internal/services/SearchResultsServiceImpl.java I think we need to modify the condition and check for both key and order from the params: if (sortKeyParam.equals(key.getName()) && sortOrder.equals(key.getOrder())) { keyImpl.setSelected(true); sorter.setCurrentKey(key); keyOrder = sortOrder; resultSorterKey = keyImpl; } else if (keyOrder == null) { keyOrder = sortOrder; }

Logs taken while reproducing problem

N/A

buuhuu commented 2 years ago

Tracked in CIF-2736