Skip to content

Commit

Permalink
fix(mwpw-136323): when you clear a filter group it now updates the url
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheridan Sunier committed Sep 20, 2023
1 parent cabbfa5 commit 45a94f3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dist/app.css

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions dist/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Chimera UI Libraries - Build 0.8.1 (9/8/2023, 01:47:03)
* Chimera UI Libraries - Build 0.8.2 (9/20/2023, 15:07:31)
*
*/
/******/ (function(modules) { // webpackBootstrap
Expand Down Expand Up @@ -6842,16 +6842,19 @@ var Container = function Container(props) {
* @returns {Void} - an updated state
*/
var clearFilterItem = function clearFilterItem(id) {
var group = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

setFilters(function (prevFilters) {
var filterClearedState = getFilterItemClearedState(id, prevFilters);
return filterClearedState;
});

var urlParams = new URLSearchParams(window.location.search);
clearUrlState();
// actually clear the url state
urlParams.forEach(function (value, key) {
var chFilter = key.toLowerCase().replace('ch_', '').replace(' ', '-');
if (key.indexOf(filterGroupPrefix) !== 0 || !id.includes(chFilter)) {
if (key.indexOf(filterGroupPrefix) !== 0 || !id.toLowerCase().includes(chFilter) || !group.toLowerCase().includes(chFilter)) {
setUrlState(key, value.replace('%20', ' '));
}
});
Expand Down Expand Up @@ -55551,7 +55554,7 @@ var Item = function Item(props) {
* @listens ClickEvent
*/
var handleClear = function handleClear() {
return onClearAll(id);
onClearAll(id, name);
};

/**
Expand Down Expand Up @@ -55624,6 +55627,7 @@ var Item = function Item(props) {
),
shouldRenderSelectedBadge && _react2.default.createElement(_SelectedItem.SelectedItem, {
handleClear: handleClear,
id: id + '-clear',
numItemsSelected: numItemsSelected }),
_react2.default.createElement(
'section',
Expand Down
6 changes: 3 additions & 3 deletions dist/main.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/main.source.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions react/src/js/components/Consonant/Container/Container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,17 +429,19 @@ const Container = (props) => {
* @param {Number} id - the id of an individual filter item
* @returns {Void} - an updated state
*/
const clearFilterItem = (id) => {
const clearFilterItem = (id, group = '') => {
setFilters((prevFilters) => {
const filterClearedState = getFilterItemClearedState(id, prevFilters);
return filterClearedState;
});

const urlParams = new URLSearchParams(window.location.search);
clearUrlState();
// actually clear the url state
urlParams.forEach((value, key) => {
const chFilter = key.toLowerCase().replace('ch_', '').replace(' ', '-');
if (key.indexOf(filterGroupPrefix) !== 0 || !id.includes(chFilter)) {
if (key.indexOf(filterGroupPrefix) !== 0 || !id.toLowerCase().includes(chFilter) ||
!group.toLowerCase().includes(chFilter)) {
setUrlState(key, value.replace('%20', ' '));
}
});
Expand Down
5 changes: 4 additions & 1 deletion react/src/js/components/Consonant/Filters/Left/Item.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ const Item = (props) => {
* @param {ClickEvent} e
* @listens ClickEvent
*/
const handleClear = () => onClearAll(id);
const handleClear = () => {
onClearAll(id, name);
};

/**
* Handles toggling the selected/unselected state of the left filter option
Expand Down Expand Up @@ -205,6 +207,7 @@ const Item = (props) => {
shouldRenderSelectedBadge &&
<DesktopSelectedItem
handleClear={handleClear}
id={`${id}-clear`}
numItemsSelected={numItemsSelected} />
}
<section
Expand Down

0 comments on commit 45a94f3

Please sign in to comment.