Skip to content

Add sidebar filters menu - #6

Merged
annehaley merged 6 commits into
mainfrom
sidebar-faceted-search
Jul 27, 2026
Merged

Add sidebar filters menu#6
annehaley merged 6 commits into
mainfrom
sidebar-faceted-search

Conversation

@annehaley

@annehaley annehaley commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

This PR adds a filters menu to the sidebar which allows users to specify values of other attributes in their search. If filters are applied in the sidebar when the user clicks on a package in the results, the same filters will be applied to the specs table for that package.

image

Preview available at https://annehaley.github.io/spack-cache/

@annehaley
annehaley requested a review from zackgalbreath July 8, 2026 13:57
Comment thread templates/static/script.js Outdated
if (releaseName) newUrl += `&release=${releaseName}`;
for (const key in sidebarFilters) {
for (const value of sidebarFilters[key]) {
newUrl += `&${key}=${value}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to URL-encoded the value here (or use URLSearchParams) to preserve special variant characters like "+".

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, in 6b68cda, I changed this function to create the redirect with new URL(...).searchParams.append(...), which does automatic encoding of the params

Comment thread templates/static/script.js Outdated
function clearAllSidebarFilters() {
sidebarFilters = {};
const menuContent = document.getElementById('filters-menu-content');
$(menuContent).find('button.checked').each((index, button) => { toggleCheckbox(button) });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are leaving stale .checked classes behind on these buttons here. Compare with line 545 above where we explicitly remove this class.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, that left the checked class around even though the checkbox becomes unchecked. I explicitly remove the checked class in ac7f706.

Comment thread templates/sidebar.html Outdated
</div>
</div>
</div>
</div> No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an extra / imbalanced </div> that can be removed

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in c0211ee

Comment thread templates/static/script.js Outdated
for (const key in sidebarFilters) {
const valueSpecs = attrValueSpecs[key] || attrValueSpecs[key + 's'];
for (value of sidebarFilters[key]) {
matchComplete &= !!valueSpecs[value];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the logical operator (&&=) instead of the bitwise operator here? Or we could really spell it out:

matchComplete = matchComplete && !!valueSpecs[value];

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I often confuse the two operators. Changed both occurrences in 763e4b7.

Comment thread templates/static/script.js Outdated
}
}
}
match &= matchComplete && matchingSpecs && matchingSpecs.size > 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my fear of bitwise operations also applies here

@annehaley
annehaley requested a review from zackgalbreath July 24, 2026 19:52
@annehaley
annehaley merged commit 755fba2 into main Jul 27, 2026
@annehaley
annehaley deleted the sidebar-faceted-search branch July 27, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants