diff --git a/.changeset/sour-monkeys-film.md b/.changeset/sour-monkeys-film.md new file mode 100644 index 00000000000..9ba8e35656a --- /dev/null +++ b/.changeset/sour-monkeys-film.md @@ -0,0 +1,5 @@ +--- +'codemirror-graphql': patch +--- + +fix info tooltips to work when Graphiql is not used as full page diff --git a/packages/codemirror-graphql/src/utils/info-addon.ts b/packages/codemirror-graphql/src/utils/info-addon.ts index 14ff3bdba35..5b017faae8d 100644 --- a/packages/codemirror-graphql/src/utils/info-addon.ts +++ b/packages/codemirror-graphql/src/utils/info-addon.ts @@ -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;