Skip to content

fix: show active filter indicators#231

Merged
jbampton merged 4 commits into
john-bampton:mainfrom
santoslgl01-web:fix/issue-145-active-filter-indicator
Apr 30, 2026
Merged

fix: show active filter indicators#231
jbampton merged 4 commits into
john-bampton:mainfrom
santoslgl01-web:fix/issue-145-active-filter-indicator

Conversation

@santoslgl01-web

Copy link
Copy Markdown
Contributor

Summary

Fixes #145

Adds a visible active filter/sort indicator so users can immediately see why the current developer list is narrowed or ordered differently.

Changes

  • Shows active filters and non-default sorting as compact badges in both sidebar and desktop results areas
  • Adds a "Clear all" action directly in the indicator
  • Reuses one shared default-filter map for both the reset button and the active-state summary
  • Adds styling for sidebar and desktop indicator badges

Testing

  • python3 -m py_compile render.py fetch.py generate_featured.py
  • python3 render.py (HTML generated; existing sitemap safe-path warning still appears)
  • node --check docs/script.js
  • Manual browser smoke test via local python3 -m http.server: entering sindre showed Active: Search: sindre and filtered the list to 1 result with no console errors

@deepsource-io

deepsource-io Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

DeepSource Code Review

We reviewed changes in 8fe7ed0...dbe33e0 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Secrets Apr 30, 2026 2:57a.m. Review ↗
Python Apr 30, 2026 2:57a.m. Review ↗
JavaScript Apr 30, 2026 2:57a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces active filter indicators to the user interface, allowing users to see which filters are currently applied and providing a 'Clear all' button. The implementation includes new logic in script.js to track filter states against default values, CSS for styling badges and labels, and HTML updates for both mobile and desktop views. Feedback focuses on improving the robustness of filter summary generation by handling whitespace-only inputs and optimizing performance by passing pre-calculated filter summaries to the rendering functions to avoid redundant processing.

Comment thread docs/script.js
Comment on lines +1083 to +1091
function getActiveFilterSummaries() {
return Object.entries(DEFAULT_FILTER_VALUES)
.map(([id, defaultValue]) => {
const element = document.getElementById(id);
if (!element || element.value === defaultValue) return null;
return `${FILTER_LABELS[id]}: ${getControlDisplayValue(element)}`;
})
.filter(Boolean);
}

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.

medium

The current implementation of getActiveFilterSummaries can produce badges with empty values (e.g., "Search: ") if a user enters only whitespace into a text input. It is better to verify that the display value is not empty before including it in the summary list.

Suggested change
function getActiveFilterSummaries() {
return Object.entries(DEFAULT_FILTER_VALUES)
.map(([id, defaultValue]) => {
const element = document.getElementById(id);
if (!element || element.value === defaultValue) return null;
return `${FILTER_LABELS[id]}: ${getControlDisplayValue(element)}`;
})
.filter(Boolean);
}
function getActiveFilterSummaries() {
return Object.entries(DEFAULT_FILTER_VALUES)
.map(([id, defaultValue]) => {
const element = document.getElementById(id);
if (!element || element.value === defaultValue) return null;
const displayValue = getControlDisplayValue(element);
return displayValue ? `${FILTER_LABELS[id]}: ${displayValue}` : null;
})
.filter(Boolean);
}

Comment thread docs/script.js Outdated
Comment on lines +1093 to +1097
function renderActiveFilterIndicator(container) {
if (!container) return;

const activeFilters = getActiveFilterSummaries();
if (!activeFilters.length) {

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.

medium

To avoid redundant processing, renderActiveFilterIndicator should accept the pre-calculated activeFilters array as an argument instead of calling getActiveFilterSummaries() internally. This is especially important since this function is called multiple times (for both mobile and desktop containers) on every filter change.

function renderActiveFilterIndicator(container, activeFilters) {
  if (!container) return;

  if (!activeFilters.length) {

Comment thread docs/script.js
Comment on lines +1126 to +1131
function updateActiveFilterIndicators() {
renderActiveFilterIndicator(document.getElementById('activeFiltersSummary'));
renderActiveFilterIndicator(
document.getElementById('activeFiltersSummaryDesktop'),
);
}

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.

medium

Calculate the active filter summaries once and pass them to the rendering functions to improve efficiency and avoid redundant DOM lookups and string processing.

function updateActiveFilterIndicators() {
  const activeFilters = getActiveFilterSummaries();
  renderActiveFilterIndicator(
    document.getElementById('activeFiltersSummary'),
    activeFilters,
  );
  renderActiveFilterIndicator(
    document.getElementById('activeFiltersSummaryDesktop'),
    activeFilters,
  );
}

@santoslgl01-web

Copy link
Copy Markdown
Contributor Author

Updated per the review feedback: whitespace-only text inputs no longer render empty active-filter badges, and active filter summaries are now calculated once and passed to both indicator renderers. Re-ran node --check docs/script.js and git diff --check.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an “Active filters / sort” summary to the developer list UI so users can quickly understand why the results are filtered/sorted, with a one-click “Clear all” action.

Changes:

  • Adds active filter/sort summary containers to both sidebar and desktop results areas.
  • Introduces JS logic to compute active filter badges and render them (plus a “Clear all” button), reusing a shared default-values map for reset + summary.
  • Adds CSS styles for the summary badges and clear action in sidebar and desktop contexts.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
layouts/layout.html Adds DOM placeholders for active filter/sort summaries in sidebar + desktop results areas.
docs/styles.css Styles the active filter summary container, badges, and “Clear all” button (including desktop overrides).
docs/script.js Computes active filter/sort summaries from current control values and renders badges; reuses shared defaults for reset.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/script.js
Comment on lines 739 to 747
function updateVisibilityAndSort() {
const sortBy = document.getElementById('sortBy').value;
const sortedUsers = getSortedUsers(sortBy);

renderCards(sortedUsers);
updateCounts(sortedUsers);
updateResultsMessage(sortedUsers);
updateActiveFilterIndicators();
}

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

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

updateActiveFilterIndicators() now shows the currently selected sort label as an active badge, but the sortBy <select> includes followers-growth-desc / followers-growth-asc options (in layouts/layout.html) that are not implemented in getSortedUsers()’s sorters map. Selecting those sorts will display an active sort badge even though no corresponding sort is applied. Either implement these two sorters or remove/disable the unsupported options to keep the indicator accurate.

Copilot uses AI. Check for mistakes.
Comment thread docs/script.js
Comment on lines +1083 to +1091
function getActiveFilterSummaries() {
return Object.entries(DEFAULT_FILTER_VALUES)
.map(([id, defaultValue]) => {
const element = document.getElementById(id);
if (!element || element.value === defaultValue) return null;
const displayValue = getControlDisplayValue(element);
return displayValue ? `${FILTER_LABELS[id]}: ${displayValue}` : null;
})
.filter(Boolean);

Copilot AI Apr 27, 2026

Copy link

Choose a reason for hiding this comment

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

getActiveFilterSummaries() trims the displayed value for text inputs, but it decides “active vs default” using the raw element.value. For searchInput, the filter logic currently uses .value.toLowerCase() without .trim() (see getActiveFilters()), so whitespace-only input will (a) filter out results while (b) producing no active badge because displayValue becomes empty and is dropped. Consider trimming searchInput in the filter logic and using the same trimmed value when determining whether a text input deviates from its default, so the indicator and filtering behavior stay consistent.

Copilot uses AI. Check for mistakes.
@santoslgl01-web

Copy link
Copy Markdown
Contributor Author

Hi! Just checking in — please let me know if any changes are needed. Happy to update the PR. Thanks! 🙂

@jbampton jbampton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks 🏂

@jbampton jbampton merged commit 2688bf1 into john-bampton:main Apr 30, 2026
4 of 6 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Turbo Apr 30, 2026
@jbampton jbampton added the $1 label May 1, 2026
@jbampton

jbampton commented May 1, 2026

Copy link
Copy Markdown
Member

Hey @santoslgl01-web you have earned $1 for this PR

We pay with GitHub Sponsors so you will need a profile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

13. Clear Filter/Sort Indicator

3 participants