Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code line numbers overlap with line content. #980

Closed
AshkanArabim opened this issue Aug 1, 2022 · 7 comments
Closed

Code line numbers overlap with line content. #980

AshkanArabim opened this issue Aug 1, 2022 · 7 comments

Comments

@AshkanArabim
Copy link

MDN URL

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign

What specific section or headline is this issue about?

"Try it"

What information was incorrect, unhelpful, or incomplete?

Nothing was incorrect.
There is a problem with the layout of the editable code box under "Try it" where line numbers overlap code and make code hard to read.

What did you expect to see?

For line numbers to not overlap with code.

Do you have any supporting links, references, or citations?

https://imgur.com/rt0YFBv

Do you have anything more you want to share?

Steps to reproduce:
1- Open "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign" with Firefox.
2- Check the "Try it" section.

MDN metadata

Page report details
@github-actions github-actions bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Aug 1, 2022
@Josh-Cena
Copy link
Member

I've also hit it in the past, and there are duplicate issues: mdn/content#13531

This isn't reproduced consistently in my browser—in fact, probably once every 100 visits—and usually works after a refresh. But I have a feeling this has something to do with wrong hydration order. @mdn/core-dev it's probably a pain but could you investigate?

@sideshowbarker sideshowbarker transferred this issue from mdn/content Aug 2, 2022
@mirunacurtean mirunacurtean removed the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Aug 2, 2022
@mirunacurtean
Copy link

Managed to temporarily reproduce it in Chrome but after navigating the site for a while it no longer occurs.
image

@anrusina
Copy link

anrusina commented Aug 3, 2022

Not a consistent repro. Navigation using links inside the page - persists the issue. Full Refresh (F5) of the page - clears the issue.
When issue occurs each line of code rendered as:

// each line of code
<div style="position: relative;">
  <div class="CodeMirror-gutter-wrapper" aria-hidden="true" contenteditable="false" style="left: 0px;">
    <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 1px;">2</div>
  </div>
  <pre class=" CodeMirror-line " role="presentation">
    <span role="presentation" style="padding-right: 0.1px;">
       <span class="cm-comment">// expected output: 23</span>
     </span>
   </pre>
 </div>
 // left section containing line numbers
 <div class="CodeMirror-gutters" style="height: 258px;">
    <div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 1px;">
    </div>
 </div>

With proper render:

// each line of code
<div style="position: relative;">
   <div class="CodeMirror-gutter-wrapper" aria-hidden="true" contenteditable="false" style="left: -30px;">
      <div class="CodeMirror-linenumber CodeMirror-gutter-elt" style="left: 0px; width: 21px;">2</div>
   </div>
   <pre class=" CodeMirror-line " role="presentation">
      <span role="presentation" style="padding-right: 0.1px;">
         <span class="cm-comment">// expected output: 23</span>
      </span>
   </pre>
</div>
// left section containing line numbers
<div class="CodeMirror-gutters" style="height: 257px;">
    <div class="CodeMirror-gutter CodeMirror-linenumbers" style="width: 29px;">
    </div>
</div>

Main differences:
left: 0px vs left: -30px
width: 1px vs width: 21px
width: 1px; vs width:29px;

Looks like Code related component has an issue with maintaining showLineNumbers state, and sometimes got into state when numbers are shown but component set all styling as they are hidden.

@anrusina
Copy link

anrusina commented Aug 3, 2022

Was able to get repro with 3/5 rate.

  1. Open page https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol ,
  2. find `Symbol.isConcatSpreadable
  3. Select and click "Open link in new tab"
  4. Observe

Google Chrome Version 103.0.5060.134 (Official Build) (x86_64)

@caugner
Copy link
Contributor

caugner commented Aug 26, 2022

FWIW @NiedziolkaMichal has reported the issue upstream: codemirror/codemirror5#6953

@NiedziolkaMichal
Copy link
Member

@caugner Yes, but issue is with our implementation of code mirror. Version 6 was released quite recently which I think wouldn't have this problem(we use 5.65.8), but its API is significantly different. I could work on upgrading it, but currently I have 6 PRs in BOB waiting for a review, so its likely that I would be wasting my time.

@caugner caugner transferred this issue from mdn/yari Nov 15, 2022
@caugner
Copy link
Contributor

caugner commented Nov 15, 2022

Duplicate of #976.

@caugner caugner closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

6 participants