Skip to content

Commit

Permalink
fix: Stop a tag with href of 'javascript:void 0' from navigating (#3567)
Browse files Browse the repository at this point in the history
* fix: prevent default behavior of clicking a tag href. Closes #3565

* added changeset
  • Loading branch information
retrodaredevil authored Mar 26, 2024
1 parent 7e86dc4 commit fc7de5a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-rules-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'codemirror-graphql': patch
---

tooltip a tag's click listener calls event.preventDefault() to stop navigating away from page
3 changes: 3 additions & 0 deletions packages/codemirror-graphql/src/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ function text(
// want clicking the node to navigate anywhere.
node.href = 'javascript:void 0'; // eslint-disable-line no-script-url
node.addEventListener('click', (e: MouseEvent) => {
// Although an href of 'javascript:void 0' should never navigate away from the page,
// that is not always the case: https://github.com/graphql/graphiql/issues/3565
e.preventDefault();
onClick(ref, e);
});
} else {
Expand Down

0 comments on commit fc7de5a

Please sign in to comment.