Skip to content

Commit

Permalink
Fix click on blob line in references panel causing a full browser ref…
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp-spiess committed Feb 22, 2023
1 parent 3b250c2 commit 9d4dbba
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LineLinkManager implements PluginValue {
line.to,
Decoration.mark({
tagName: 'a',
attributes: { href, 'data-line-link': '' },
attributes: { href, 'data-cm-line-link': '' },
class: 'text-decoration-none',
})
)
Expand All @@ -50,11 +50,13 @@ export const navigateToLineOnAnyClickExtension: Extension = [
EditorView.domEventHandlers({
click(event, view) {
const target = event.target as HTMLElement
// Check to see if the clicked target is a token link.
// If it is, push the link to the history stack.
if (target.matches('[data-line-link]')) {
const closest = target.closest('[data-cm-line-link]')

// Check to see if the clicked target is a or is inside a token link.
// If it is, navigate to the link.
if (closest) {
event.preventDefault()
const href = target.getAttribute('href')!
const href = closest.getAttribute('href')!
const props = view.state.facet(blobPropsFacet)
if (props.nav) {
props.nav(href)
Expand Down

0 comments on commit 9d4dbba

Please sign in to comment.