Skip to content

Conversation

@IEvangelist
Copy link
Member

the "Aspire" title and search should appear in the header

Related to #179

Copilot AI review requested due to automatic review settings January 9, 2026 18:26
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

This PR enhances the homepage header by adding a search component and making both the search bar and the "Aspire" title appear in the header when scrolling past the hero section. The implementation removes a previously hidden datetime display and adds scroll-based visibility toggling.

  • Adds Search component import and integration into the homepage header
  • Implements scroll-based visibility logic to show/hide search and title based on hero section position
  • Removes the hidden datetime component that was previously in the title wrapper

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

const searchWrapper = document.querySelector('[data-homepage-search]');
const titleWrapper = document.querySelector('[data-homepage-title]');
const siteTitleText = titleWrapper?.querySelector('.site-title .sr-only');
if (!searchWrapper && !siteTitleText) return;
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The early return condition uses AND (&&) but should use OR (||). If either searchWrapper or siteTitleText is null, the function should return early since the scroll logic depends on both elements existing. With the current logic, the function continues even when one of the elements is missing, leading to potential issues when trying to add/remove classes from null elements.

Suggested change
if (!searchWrapper && !siteTitleText) return;
if (!searchWrapper || !siteTitleText) return;

Copilot uses AI. Check for mistakes.
checkScroll();

// Check on scroll
window.addEventListener('scroll', checkScroll, { passive: true });
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

Each time initHomepageHeader is called, a new scroll event listener is added without removing the previous one. This creates a memory leak and causes checkScroll to be called multiple times per scroll event after page transitions. Consider storing the listener reference and removing it before adding a new one, or use an AbortController to manage the listener lifecycle.

Copilot uses AI. Check for mistakes.
}

function checkScroll() {
const heroRect = hero!.getBoundingClientRect();
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

Using TypeScript non-null assertion operator (!) in a plain JavaScript context. Since this is not a TypeScript file, the exclamation mark should be removed. The null check has already been performed at line 45, so accessing hero is safe within this function scope without the assertion operator.

Suggested change
const heroRect = hero!.getBoundingClientRect();
const heroRect = hero.getBoundingClientRect();

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +68
// Check on initial load
checkScroll();

// Check on scroll
window.addEventListener('scroll', checkScroll, { passive: true });
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The checkScroll function is called on every scroll event without any throttling or debouncing. This can cause performance issues with frequent DOM operations (classList manipulations) during rapid scrolling. Consider implementing throttling or using requestAnimationFrame to optimize scroll performance.

Suggested change
// Check on initial load
checkScroll();
// Check on scroll
window.addEventListener('scroll', checkScroll, { passive: true });
let ticking = false;
function onScroll() {
if (!ticking) {
ticking = true;
window.requestAnimationFrame(() => {
checkScroll();
ticking = false;
});
}
}
// Check on initial load
checkScroll();
// Check on scroll (throttled with requestAnimationFrame)
window.addEventListener('scroll', onScroll, { passive: true });

Copilot uses AI. Check for mistakes.
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