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.

codemirror widths and lefts are so large they push codemirror to right edge of browser

See original GitHub issue

using babel and webpack-dev-server to bundle and serve the the rendered GraphiQL component. For some reason the margin-left and certain width style properties are set to almost the entire width of the screen so all i see is a blank space and then the first character of each code line up against the right side of the browser window

<div class="CodeMirror-sizer" style="margin-left: 1904px; margin-bottom: 0px; border-right-width: 30px; min-height: 675px; min-width: 619px; padding-right: 0px; padding-bottom: 0px;">
   <div ....>....
  </di>
</div>

screen shot 2015-09-15 at 11 03 30 pm

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
philiptzoucommented, Jul 27, 2017

I encountered the same problem recently. After dived into the source code of CodeMirror and fixed my issue I think it is better to share my experience here. In case someone else get stuck by this really weird, tricky issue.

TL;DR: Find a way to ensure graphiql.css is loaded before <GraphiQL /> get rendered. Be very careful when playing with Webpack code-splitting and GraphiQL at the same time.

My problem is highly related with the differences of the style processing between dev and prod of a customized version of start-react-app. I also used “code splitting” technique to split the GraphiQL and CodeMirror from the main bundle.

In general, in dev mode all styles are loaded in inline <style> block by style-loader and there’s no problem. However, in prod mode, instead of being added to main.css, the graphiql.css was added to the chunk file which contained CodeMirror and GraphiQL.

It took me a lot of hours trying to upgrade my old react-relay to the newest version (since apparently the graphiql package required graphql@^0.10.5 via codemirror-graphql via graphql-language-service-interface) therefore I can upgrade graphiql to the newest one. However after the upgrading I found the problem existing with the newest version. Then I started to set breakpoints and debug CodeMirror. Then I found without the proper style, .CodeMirror-gutter.CodeMirror-foldgutter became “display: block” instead of “display: inline-block”. The width of that element cascaded to all its parent elements and caused the disaster. Even graphiql.css was loaded immediately after the initialization, the mess didn’t go away.

Once found the problem, I changed my code to ensure that graphiql.css must be loaded before <GraphiQL /> get rendered. The problem was gone.

0reactions
philiptzoucommented, Aug 15, 2018

@hotgazpacho I think any value larger than 0 for setInterval() is acceptable as long as the delay isn’t perceptible to the user. How about 100?

Read more comments on GitHub >

github_iconTop Results From Across the Web

CodeMirror 5 User Manual
User manual and reference guide version 5.65.11. CodeMirror is a code-editor component that can be embedded in Web pages. The core library provides...
Read more >
Reference Manual - CodeMirror
Reference Manual. CodeMirror is published as a set of NPM packages under the @codemirror scope. The core packages are listed in this reference...
Read more >
CodeMirror System Guide
System Guide. This is the guide to the CodeMirror editor system. It provides a prose description of the system's functionality. For the item-by-item ......
Read more >
Are these styles all right, or is this intervening too much into ...
I'm using markdown language, and I would like to highlight CodeBlock elements, for the whole line, but not from the left of the...
Read more >
Internals - CodeMirror
ACE uses its hidden textarea only as a text input shim, and does all cursor movement and things like text deletion itself by...
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