Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

Issue

Fixes issue where filter buttons scroll the page instead of filtering items when the projects template is reused for custom sections (e.g., "Talks, Posters & Conferences").

Description

Root cause: Template generated hardcoded IDs. When reused, getElementById() only found the first section, leaving others uninitialized.

Template (layouts/partials/sections/projects.html):

  • Made IDs unique per section: project-card-holder-{{ $sectionID }}, project-filter-buttons-{{ $sectionID }}
  • Added data-section="{{ $sectionID }}" to containers and buttons

JavaScript (assets/scripts/sections/projects.js):

  • Changed from getElementById() to querySelectorAll('.filtr-projects')
  • Initialize separate Filterizr instance per section with scoped control selectors

Each section now filters independently.

Test Evidence

Setup: Create a custom section reusing the projects template:

# data/sections/conferences.yaml
section:
  name: Talks, Posters & Conferences
  id: conferences
  template: sections/projects.html
  enable: true

buttons:
- name: All
  filter: "all"
- name: Talk
  filter: "talk"
- name: Poster
  filter: "poster"

projects:
- name: "Example Poster"
  tags: ["poster"]
- name: "Example Talk"
  tags: ["talk"]

Verify:

  1. Both original Projects section and custom section appear on page
  2. Filter buttons in each section only affect that section's items
  3. No page scrolling when clicking filters
  4. Filtering animation works correctly in both sections
Original prompt

This section details on the original issue you should resolve

<issue_title>Duplicate Projects Section</issue_title>
<issue_description>Hello,

I’m trying to reuse the Toha projects section template to create a custom section called Talks, Posters & Conferences.

My config.yaml looks like this:

section:
  name: Talks, Posters & Conferences
  id: conferences
  template: sections/projects.html
  enable: true
  weight: 7
  showOnNavbar: true

buttons:
- name: All
  filter: "all"
- name: Talk
  filter: "talk"
- name: Poster
  filter: "poster"
- name: Contribution
  filter: "contribution"

projects:
- name: "Example Poster"
  role: Example Conference
  timeline: "2025"
  summary: "Short description"
  tags: ["poster"]

Problem:
The section renders correctly, but when I click on the filter buttons the behavior is not the expected filtering animation. Instead, the page scrolls as if the buttons were anchors (e.g. #talk).

Expected behavior:
Filter buttons should hide/show cards in the new section the same way as in the default Projects section.

Thank you very much for your availability and support! </issue_description>

<agent_instructions>Make sure to keep code consistent with repository. Also, add instruction in the PR comment on how to test it.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@hossainemruz Do you have any live example site where I can check the behavior?

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 11, 2025
@netlify
Copy link

netlify bot commented Nov 11, 2025

Deploy Preview for toha-ci ready!

Name Link
🔨 Latest commit 21f70a6
🔍 Latest deploy log https://app.netlify.com/projects/toha-ci/deploys/6913da747231cf00080c7e27
😎 Deploy Preview https://deploy-preview-1098--toha-ci.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI and others added 2 commits November 11, 2025 23:54
Co-authored-by: hossainemruz <12577390+hossainemruz@users.noreply.github.com>
Co-authored-by: hossainemruz <12577390+hossainemruz@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix filter button behavior in Talks, Posters & Conferences section Fix filter buttons when reusing projects template for multiple sections Nov 11, 2025
Copilot AI requested a review from hossainemruz November 11, 2025 23:59
@hossainemruz hossainemruz marked this pull request as ready for review November 12, 2025 00:49
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

@hossainemruz hossainemruz added the bug-fix Bug fixes label Nov 12, 2025
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

@hossainemruz hossainemruz merged commit 645585a into main Nov 12, 2025
12 checks passed
@hossainemruz hossainemruz deleted the copilot/fix-filter-button-behavior branch November 12, 2025 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate Projects Section

2 participants