gatsby-remark-vscode icon indicating copy to clipboard operation
gatsby-remark-vscode copied to clipboard

Table layout causes diff and line highlight errors

Open robertg042 opened this issue 4 years ago • 3 comments

Hi, first of all, thanks for the awesome plugin!

While testing in IE and in modern webkit browsers, I discovered few issues. The common culprit seems to be usage of table layout and the fact that relative positioning of elements is not always respected in this layout.

  1. In IE line hightlight is not displayed at all, because of custom variables, which I guess is ok. If you set regular background-color you'll find that grvsc-line::before pseudoelement is mispositioned:

IE with custom background

  1. In modern Chrome, Safari and Edge, however, position: relative on display: table-row on grvsc-line is not respected, which results in width: 100% applied to grvsc-line::before being equal to the width of grvsc-container and not grvsc-line. It causes problems with highlight beyond horizontal overflow:

chrome, diff, not scrolled

chrome, diff, scrolled

chrome, highlight, not scrolled

chrome, highlight, scrolled

Those styles seems to work as a workaround:

  .grvsc-code {
    position: relative;
    width: 100%;
  }
  .grvsc-line {
    position: static;
  }

Firefox has no issues:

firefox

Sources:

robertg042 avatar Feb 16 '21 21:02 robertg042

Hmm, you’re very correct... unfortunately, making .grvsc-code 100% wide when the code doesn’t take up the full width makes the gutter cells grow (they’re supposed to be flush left):

image

I’ll keep experimenting. Thanks for the heads up!

andrewbranch avatar Feb 18 '21 00:02 andrewbranch

Thanks for looking into the issue. I admit I haven't run the tests while testing my solution. It's just what works for me right now.

robertg042 avatar Feb 19 '21 16:02 robertg042

I think CSS Grid might be a viable solution here. Not sure when I’ll have time to give it a try.

andrewbranch avatar Mar 21 '21 21:03 andrewbranch