Skip to content

fix: restore gsoc dropdown on program pages#7431

Open
rishiraj38 wants to merge 5 commits intolayer5io:masterfrom
rishiraj38:fix-gsoc-dropdown
Open

fix: restore gsoc dropdown on program pages#7431
rishiraj38 wants to merge 5 commits intolayer5io:masterfrom
rishiraj38:fix-gsoc-dropdown

Conversation

@rishiraj38
Copy link
Contributor

@rishiraj38 rishiraj38 commented Feb 19, 2026

Description

This PR fixes #7430 where the program year dropdown (e.g., to switch between GSoC 2024, 2025, etc.) was missing on individual program pages. It also resolves a runtime error caused by the dropdown component's change handler.

Notes for Reviewers

  • Unified Templates: Updated gatsby-node.js to use MultiProgramPostTemplate for all program pages (both main and individual years), ensuring consistent dropdown availability.

  • Context Passing: Passed the program name in the page context to allow fetching sibling program years.

  • State Initialization: Updated src/templates/program-multiple.js to initialize the active dropdown option based on the current page's URL (pageContext.slug).

  • Bug Fix: Fixed src/sections/Careers/Careers-Programs-single/index.js to pass the value directly to setActiveOption instead of a function updater, preventing a crash in navigate().

Signed commits

  • Yes, I signed my commits.

Signed-off-by: Rishi Raj <rishiraj438gt@gmail.com>
@rishiraj38
Copy link
Contributor Author

@Rajesh-Nagarajan-11 Please review and Provide some feedback.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Restores the program-year dropdown on individual program pages and addresses a runtime issue related to the dropdown state updates.

Changes:

  • Pass pageContext into the multi-program template and derive the initial selected dropdown option from the current page slug.
  • Simplify the dropdown onChange handler to set the selected value directly.
  • Update Gatsby page creation to use the multi-program template and include program in page context.

Reviewed changes

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

File Description
src/templates/program-multiple.js Initializes the dropdown selection based on the current program page slug.
src/sections/Careers/Careers-Programs-single/index.js Updates dropdown onChange to set state directly.
gatsby-node.js Switches program pages to the multi-program template and passes additional context.

Comment on lines 26 to 32
const ProgramsPage = ({ data, children, pageContext }) => {
const programs = data.allMdx.nodes;
const { navigate } = require("gatsby");

const initialIndex = programs.findIndex((program) => program.fields.slug === pageContext.slug);
const [activeOption] = useState(initialIndex !== -1 ? initialIndex : 0);

Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

useState is only destructuring activeOption, so there is no setActiveOption available from this state hook. Since the dropdown component uses setActiveOption (see ProgramsSingle props/onChange), this can still lead to runtime errors or a non-functional dropdown. Update this hook to also capture the setter (e.g., [activeOption, setActiveOption]), and ensure the setter is the one being passed down to the dropdown component.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rishiraj38 ^^

I’m trying to implement it but pages are breaking. I’m looking for the reason and a fix.

@l5io
Copy link
Contributor

l5io commented Feb 19, 2026

🚀 Preview for commit 1a8b645 at: https://699746eec1bafb400b273c9e--layer5.netlify.app

Signed-off-by: Rishi Raj <rishiraj438gt@gmail.com>
@l5io
Copy link
Contributor

l5io commented Feb 19, 2026

🚀 Preview for commit 74b1896 at: https://6997534a7effb87571ad0233--layer5.netlify.app

@l5io
Copy link
Contributor

l5io commented Feb 19, 2026

🚀 Preview for commit 85f7b32 at: https://69976c74bf89d44d7d12c729--layer5.netlify.app

@Rajesh-Nagarajan-11
Copy link
Member

Rajesh-Nagarajan-11 commented Feb 20, 2026

why i can feel the latency when i switch years ? @rishiraj38

@rishiraj38
Copy link
Contributor Author

why i can feel the latency when i switch years ? @rishiraj38

The latency occurs because selecting a year in the dropdown triggers a navigation event via navigate(). Consequently, every time we choose a new year from the dropdown Gatsby must fetch the data and render it.

@saurabhraghuvanshii
Copy link
Member

why i can feel the latency when i switch years ? @rishiraj38

The latency occurs because selecting a year in the dropdown triggers a navigation event via navigate(). Consequently, every time we choose a new year from the dropdown Gatsby must fetch the data and render it.

Don't use usestate, check another option like usememo . I think usememo can improve latency

@l5io
Copy link
Contributor

l5io commented Feb 20, 2026

🚀 Preview for commit a228a3a at: https://699808c8511b23370240c481--layer5.netlify.app

…ng useMemo

Signed-off-by: Rishi Raj <rishiraj438gt@gmail.com>
@l5io
Copy link
Contributor

l5io commented Feb 20, 2026

🚀 Preview for commit 32fe9d0 at: https://69980f2528828b630b708121--layer5.netlify.app

@rishiraj38
Copy link
Contributor Author

There’s still a bit of latency when first loading the pages.

@saurabhraghuvanshii
Copy link
Member

@rishiraj38 only for first attempt after that it works well

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to switch GSoC years

5 participants

Comments