Skip to content

Commit

Permalink
fix: fix config changes filter by cell issues around encoding and colons
Browse files Browse the repository at this point in the history
Fixes #1970
  • Loading branch information
mainawycliffe committed Jun 13, 2024
1 parent 7247c5f commit 47a5a47
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ function FilterBadge({ filters, paramKey }: FilterBadgeProps) {
(key: string, value: string) => {
const currentValue = params.get(key);
const arrayValue = currentValue?.split(",") || [];
const newValues = arrayValue.filter(
(v) => decodeURIComponent(v) !== decodeURIComponent(value)
);
const newValues = arrayValue.filter((v) => v !== value);
if (newValues.length === 0) {
params.delete(key);
} else {
Expand All @@ -51,7 +49,10 @@ function FilterBadge({ filters, paramKey }: FilterBadgeProps) {
>
<span className="text-gray-500 font-semibold">{paramKey}:</span>
<span className="text-gray-500">
{decodeURIComponent(filter.split(":")[0])}
{filter
.split(":")[0]
.replaceAll("____", ":")
.replaceAll("||||", ",")}
</span>
<span>{filter.split(":")[1] === "-1" && <FaBan />}</span>
</ClosableBadge>
Expand Down
4 changes: 3 additions & 1 deletion src/ui/DataTable/FilterByCellValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export default function FilterByCellValue({
// append the new value
const updateValue = newValues
.concat(
`${encodeURIComponent(filterValue)}:${action === "include" ? 1 : -1}`
`${filterValue.replaceAll(",", "||||").replaceAll(":", "____")}:${
action === "include" ? 1 : -1
}`
)
// remove duplicates
.filter((value, index, self) => self.indexOf(value) === index)
Expand Down
6 changes: 5 additions & 1 deletion src/ui/Dropdowns/TristateReactSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ export function tristateOutputToQueryParamValue(
const [changeType, symbol] = type.split(":");
const symbolFilter = symbol?.toString() === "-1" ? "!" : "";
return `${symbolFilter}${
encodeValue ? encodeURIComponent(changeType) : changeType
encodeValue
? encodeURIComponent(
changeType.replaceAll("____", ":").replaceAll("||||", ",")
)
: changeType.replaceAll("____", ":").replaceAll("||||", ",")
}`;
})
.join(",");
Expand Down

0 comments on commit 47a5a47

Please sign in to comment.