Skip to content
Merged
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
5 changes: 5 additions & 0 deletions packages/gitbook/src/components/hooks/useHash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export const NavigationStatusProvider: React.FC<React.PropsWithChildren> = ({ ch
}, []);

const onNavigationClick = React.useCallback((href: string) => {
// We need to skip it for search like params (i.e. ?ask= or ?q=) because they don't really trigger a navigation
// Search may trigger a navigation whenn clicking on the ask ai for example, this is not something we want to track here
if (href.startsWith('?') || href.startsWith('#')) {
return;
}
const url = new URL(
href,
typeof window !== 'undefined' ? window.location.origin : 'http://localhost'
Expand Down
3 changes: 2 additions & 1 deletion packages/gitbook/src/components/primitives/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export const Link = React.forwardRef(function Link(

const onClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
const isExternalWithOrigin = isExternalLink(href, window.location.origin);
if (!isExternal) {
// Only trigger navigation context for internal links without modifier keys (i.e. open in new tab).
if (!isExternal && !event.ctrlKey && !event.metaKey) {
onNavigationClick(href);
}

Expand Down