🐞 fix: Account for name vs slug differences

This commit is contained in:
Keith Solomon
2025-02-13 15:13:16 -06:00
parent d55e9ec3ca
commit 285960be32

View File

@@ -31,11 +31,14 @@ jQuery(document).ready(function ($) {
}
// Resource Types
selectedTypes.forEach(function (type) {
$('input[name="resource_type[]"]:checked').each(function () {
const slug = $(this).val(); // Get the slug
const name = $(this).closest('label').text().trim(); // Get the name
appliedFilters.push(
`<span class="filter-item" data-type="resource_type" data-value="${type}">
<strong>Type:</strong> ${type}
<button class="remove-filter" aria-label="Remove Type ${type}">×</button>
`<span class="filter-item" data-type="resource_type" data-value="${slug}">
<strong>Type:</strong> ${name}
<button class="remove-filter" aria-label="Remove Type ${name}">×</button>
</span>`
);
});
@@ -104,7 +107,7 @@ jQuery(document).ready(function ($) {
$('#search').val('');
} else if (filterType === 'resource_type') {
$('input[name="resource_type[]"]:checked').each(function () {
if ($(this).closest('label').text().trim() === filterValue) {
if ($(this).val() === filterValue) { // Match the slug, not the name
$(this).prop('checked', false);
}
});