mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 06:34:24 +01:00
fix(highlights): ensure quote button always navigates to quote
- Add explicit preventDefault to quote button click handler - Improve navigateToArticle error handling and logging - Ensure quote button always attempts navigation when clicked
This commit is contained in:
@@ -182,6 +182,7 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
|
||||
|
||||
// Navigate to the article that this highlight references and scroll to the highlight
|
||||
const navigateToArticle = () => {
|
||||
// Always try to navigate if we have a reference - quote button should always work
|
||||
if (highlight.eventReference) {
|
||||
// Parse the event reference - it can be an event ID or article coordinate (kind:pubkey:identifier)
|
||||
const parts = highlight.eventReference.split(':')
|
||||
@@ -204,9 +205,14 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
|
||||
openHighlights: true
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
} else if (highlight.urlReference) {
|
||||
// If eventReference is just an event ID (not a coordinate), we can't navigate to it
|
||||
// as we don't have enough info to construct the article URL
|
||||
}
|
||||
|
||||
if (highlight.urlReference) {
|
||||
// Navigate to external URL with highlight ID to trigger scroll
|
||||
navigate(`/r/${encodeURIComponent(highlight.urlReference)}`, {
|
||||
state: {
|
||||
@@ -214,7 +220,12 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
|
||||
openHighlights: true
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// If we get here, there's no valid reference to navigate to
|
||||
// This shouldn't happen for valid highlights, but we'll log it for debugging
|
||||
console.warn('Cannot navigate to article: highlight has no valid eventReference or urlReference', highlight.id)
|
||||
}
|
||||
|
||||
const handleItemClick = () => {
|
||||
@@ -545,6 +556,7 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
|
||||
title="Go to quote in article"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
navigateToArticle()
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user