Skip to content

Commit fc7de5a

Browse files
authoredMar 26, 2024··
fix: Stop a tag with href of 'javascript:void 0' from navigating (#3567)
* fix: prevent default behavior of clicking a tag href. Closes #3565 * added changeset
1 parent 7e86dc4 commit fc7de5a

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed
 

‎.changeset/sharp-rules-hide.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'codemirror-graphql': patch
3+
---
4+
5+
tooltip a tag's click listener calls event.preventDefault() to stop navigating away from page

‎packages/codemirror-graphql/src/info.ts

+3
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ function text(
299299
// want clicking the node to navigate anywhere.
300300
node.href = 'javascript:void 0'; // eslint-disable-line no-script-url
301301
node.addEventListener('click', (e: MouseEvent) => {
302+
// Although an href of 'javascript:void 0' should never navigate away from the page,
303+
// that is not always the case: https://github.com/graphql/graphiql/issues/3565
304+
e.preventDefault();
302305
onClick(ref, e);
303306
});
304307
} else {

0 commit comments

Comments
 (0)
Please sign in to comment.