Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions website/modules/asset/ui/src/initCaseStudiesFilterHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,35 @@ const emptyCleanup = function () {
// No cleanup needed
};

// Move selected (checked) tag items to the top and re-apply visibility (first 5 visible)
const reorderSelectedTagsFirst = function () {
const tagsLists = document.querySelectorAll('.tags-list');
const visibleCount = getDefaultVisibleTagsCount();

tagsLists.forEach(function (list) {
const items = Array.from(list.querySelectorAll('.tag-item'));
const active = items.filter(function (item) {
return item.classList.contains('active');
});
const inactive = items.filter(function (item) {
return !item.classList.contains('active');
});
const reordered = active.concat(inactive);

reordered.forEach(function (item) {
list.appendChild(item);
});

reordered.forEach(function (item, index) {
if (index >= visibleCount) {
item.classList.add('tag-item--hidden');
} else {
item.classList.remove('tag-item--hidden');
}
});
});
};

// Setup keyboard event handlers for filter buttons
const setupKeydownHandlers = function (filterButtons) {
const handleKeyDown = function (event) {
Expand Down Expand Up @@ -246,6 +275,7 @@ const setupShowMoreHandlers = function () {

// Initialization - Single responsibility: Set up all filter-related functionality
const initCaseStudiesFilterHandler = function () {
reorderSelectedTagsFirst();
const filterCleanup = setupFilterLinkDetection();
const accessibilityCleanup = setupFilterAccessibility();
const showMoreCleanup = setupShowMoreHandlers();
Expand Down
5 changes: 4 additions & 1 deletion website/modules/case-studies-page/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@

{% endif %}
{% if isTagSelected %}
<li class="tag-item active" data-label="{{ tag.label | lower }}">
<li
class="tag-item active{% if loop.index > data.defaultVisibleTagsCount %} tag-item--hidden{% endif %}"
data-label="{{ tag.label | lower }}"
>
{% if filterType == 'industry' %}
<a
class="tag-link"
Expand Down
Loading