question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Graphiql Explorer Plugin] (Next.js) Cursor/Caret jumps when editing query manually

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When editing the query by hand when using the GraphiQL component together with the explorerPlugin passed in the props array, the cursor resets, and appears in the first line of the editor. I’m currently implementing the plugin as stated in the README

Expected Behavior

The caret shouldn’t jump to the beginning.

Steps To Reproduce

1. Clone https://github.com/crjm/graphiql-explorer-test
2. cd into cloned repo, `npm install`
3. `npm run dev`
4. Open Explorer plugin, trigger fields
5. Start typing directly into the editor
6. The caret will jump to the first line of the editor.

Module pattern

  • graphiql-umd
  • graphiql-esm
  • graphiql-commonjs

Environment

- GraphiQL Version: latest
- OS: Ubuntu 22.04
- Browser: Firefox
- Bundler: Next.js (Webpack 5)
- `react` Version: 18.2
- `graphql` Version: 15.8

Anything else?

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

1reaction
bkuzmacommented, Nov 21, 2022

I’m experiencing the cursor jump as well and I’m using neither NextJS nor SSR 😕 I am using the explorer plugin, though I saw the problem occur when I disabled it. One thing I think I noticed: when I removed the explorer plugin along with the code that keeps the user-typed query in state (this is needed for the explorer plugin, see https://github.com/OneGraph/graphiql-explorer-example/blob/master/src/App.js#L88) and sets that query as a prop on the GraphiQL instance, I couldn’t reproduce the problem.

  • GraphiQL Version: 2.0.9
  • OS: Mac OS Ventura
  • Browser: Chrome
  • Bundler: Babel
  • react Version: 18.2.0
  • graphql Version: 16.6.0
1reaction
marcosnilscommented, Nov 8, 2022

Here’s a related conversation with a workaround.

In our case we’re using NextJS dynamic imports with without SSR capabilities as described here: https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr. If my understanding is correct, it should be the same as the outcomes you’ve shared. This issue happens only when adding the explorer plugin, so I assume there must be something happening around how both libs are being bundled and initialized in the client-side when using Next.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting JSS Next.js apps - Sitecore Documentation
Try opening the GraphiQL interface in a browser, using values from your config ( <sitecore hostname + graphQL endpoint>/ui?sc_apikey=<api key> ) ...
Read more >
apollo-server-errors | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
How To Build A GraphQL Server Using Next.js API Routes
This guide will teach you the basics of Next.js API Routes. We will start by explaining what they are and why API Routes...
Read more >
sitemap-forums2.xml - Syncfusion
... https://www.syncfusion.com/forums/141073/how-to-prevent-edit-next-cell-in- ... /forums/142661/manually-setting-totalrecordcount-pagecount-with-js-data ...
Read more >
NextJS, Contentful CMS, GraphQL, oh my! - Ben Holmes
; How to talk to GraphQL server + debug with GraphiQL; How we can roll query results into a static NextJS site with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found