Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,10 @@ exports.createPages = async ({ actions, graphql, reporter }) => {
programs.forEach((program) => {
envCreatePage({
path: program.fields.slug,
component: `${ProgramPostTemplate}?__contentFilePath=${program.internal.contentFilePath}`,
component: `${MultiProgramPostTemplate}?__contentFilePath=${program.internal.contentFilePath}`,
context: {
slug: program.fields.slug,
program: program.frontmatter.program,
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/sections/Careers/Careers-Programs-single/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const ProgramsSingle = ({ data, children, options, setActiveOption, activeOption
styles={selectStyles}
options={options}
value={options[activeOption]}
onChange={(e) => setActiveOption(() => e.value)}
onChange={(e) => setActiveOption(e.value)}
theme={dropdownTheme}
/>}
</div>
Expand Down
8 changes: 6 additions & 2 deletions src/templates/program-multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ export const query = graphql`query ProgramByName($program: String!) {
}
}`;

const ProgramsPage = ({ data, children }) => {
const [activeOption] = useState(0);
const ProgramsPage = ({ data, children, pageContext }) => {
const programs = data.allMdx.nodes;
const { navigate } = require("gatsby");

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

Comment on lines 26 to 34
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.

const options = programs.map((program) => {
let optionItem = new Object();
optionItem.label = program.frontmatter.title;
Expand Down