Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
40 changes: 0 additions & 40 deletions _site/customizations/ask-ai-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,50 +88,10 @@
return true;
}

function isAskAiOption(el) {
if (!el || el.nodeType !== 1) return false;
var option = el.closest && el.closest('[role="option"]');
if (!option) return false;
return /^\s*Can you tell me about\b/i.test(option.textContent || '');
}

function getSearchQuery() {
var input = document.querySelector('input[placeholder="Search..."]');
return input ? input.value.trim() : '';
}

function openCustomAskAi() {
var query = getSearchQuery();
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
openKapa(query);
}

function interceptAskAi(e) {
if (!isAskAiOption(e.target)) return;
e.preventDefault();
e.stopPropagation();
if (typeof e.stopImmediatePropagation === 'function') e.stopImmediatePropagation();
if (e.type === 'keydown' && e.key !== 'Enter') return;
openCustomAskAi();
}

function init() {
injectButton();
injectMobileButton();

document.addEventListener('click', interceptAskAi, true);
document.addEventListener('mousedown', interceptAskAi, true);
document.addEventListener('keydown', function (e) {
if (e.key !== 'Enter') return;
var active = document.querySelector('[role="option"][data-headlessui-state*="active"], [role="option"][aria-selected="true"]');
if (active && /^\s*Can you tell me about\b/i.test(active.textContent || '')) {
e.preventDefault();
e.stopPropagation();
if (typeof e.stopImmediatePropagation === 'function') e.stopImmediatePropagation();
openCustomAskAi();
}
}, true);

var observer = new MutationObserver(function () {
injectButton();
injectMobileButton();
Expand Down
21 changes: 14 additions & 7 deletions _site/customizations/tab-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,22 @@
setupHomepageNavbar();
patchTabButtons();
styleDropdownHeaders();
requestAnimationFrame(markNavbarReady);
markNavbarReady();

// Debounce: batch rapid React re-renders into one RAF flush so repeated
// querySelectorAll calls don't thrash the main thread on every DOM change.
var rafId = null;
var observer = new MutationObserver(function () {
applyHomepageClass();
setupHomepageNavbar();
updateLogoTheme();
patchTabButtons();
styleDropdownHeaders();
requestAnimationFrame(markNavbarReady);
if (rafId) return;
rafId = requestAnimationFrame(function () {
rafId = null;
applyHomepageClass();
setupHomepageNavbar();
updateLogoTheme();
patchTabButtons();
styleDropdownHeaders();
markNavbarReady();
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Delayed homepage class causes flicker

Medium Severity

The mutation observer now runs applyHomepageClass inside a debounced requestAnimationFrame, but navbar opacity hiding is scoped to .ch-homepage. Client-side route changes can paint at least one frame where the URL and ch-homepage disagree, so the homepage navbar may flash visible or stay hidden on the wrong page.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 208f6fb. Configure here.

});
observer.observe(document.documentElement, { childList: true, subtree: true });

Expand Down
10 changes: 5 additions & 5 deletions _site/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ body[data-scroll-locked] {
padding-right: calc(48px + 206px) !important;
}

/* Navbar hidden on initial paint; revealed by tab-nav.js once both the logo
(homepage) and CTA have been injected. Hiding during injection means no
layout shifts are visible regardless of injection order or timing. */
#navbar-transition-maple {
/* Navbar hidden only on the homepage initial paint to prevent a visible
layout shift when the logo + CTA are injected. Scoping to .ch-homepage
prevents the SPA navigation fade-in on every page change. */
.ch-homepage #navbar-transition-maple:not(.ch-navbar-ready) {
opacity: 0;
}
#navbar-transition-maple.ch-navbar-ready {
.ch-homepage #navbar-transition-maple.ch-navbar-ready {
opacity: 1;
transition: opacity 0.15s ease-out;
}
Expand Down