Skip to content

Commit

Permalink
fix: make tooltips work when Graphiql is not full page and window has…
Browse files Browse the repository at this point in the history
… scrolled (#3203)
  • Loading branch information
lesleydreyer authored Jun 1, 2023
1 parent cf590e3 commit 6198646
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-monkeys-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'codemirror-graphql': patch
---

fix info tooltips to work when Graphiql is not used as full page
11 changes: 7 additions & 4 deletions packages/codemirror-graphql/src/utils/info-addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ function onMouseOver(cm: CodeMirror.Editor, e: MouseEvent) {
}

function onMouseHover(cm: CodeMirror.Editor, box: DOMRect) {
const pos = cm.coordsChar({
left: (box.left + box.right) / 2,
top: (box.top + box.bottom) / 2,
});
const pos = cm.coordsChar(
{
left: (box.left + box.right) / 2,
top: (box.top + box.bottom) / 2,
},
'window',
); // 'window' allows to work when editor is not full page and window has scrolled

const state = cm.state.info;
const { options } = state;
Expand Down

0 comments on commit 6198646

Please sign in to comment.