-
Notifications
You must be signed in to change notification settings - Fork 282
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
Line Number Row is overflowing when it's wrapped inside a fixed height div. #381
Comments
Hi @Riken-Shah, I cannot replicate this behavior, even with ridiculously small widths the lines never break. |
Hey @rtfpessoa, I might have missed mentioning that it breaks inside a fixed-sized div where Here is the HTML code, where you can quickly reproduce the behavior (Try to scroll), <!DOCTYPE html>
<html>
<head>
<title>Report</title>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/diff2html/bundles/css/diff2html.min.css" />
<!-- Javascripts -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/diff2html/bundles/js/diff2html.min.js"></script>
</head>
<body>
<script>
document.addEventListener('DOMContentLoaded', () => {
const diffString = `===================================================================
--- backend-markdown
+++ frontend-markdown
@@ -3,11 +3,9 @@
<a href="https://github.com/jgm/commonmark.js">commonmark.js</a>, the<br>
JavaScript reference implementation.</p>
<ol>
<li>item one</li>
-<li>
-<p>item two</p>
-<ul>
+<li>item two<ul>
<li>sublist</li>
<li>sublist</li>
</ul>
</li>
@@ -17,11 +15,9 @@
<a href="https://github.com/jgm/commonmark.js">commonmark.js</a>, the<br>
JavaScript reference implementation.</p>
<ol>
<li>item one</li>
-<li>
-<p>item two</p>
-<ul>
+<li>item two<ul>
<li>sublist</li>
<li>sublist</li>
</ul>
</li>`;
const configuration = { outputFormat: 'line-by-line', drawFileList: false, matching: 'lines' };
const html = Diff2Html.html(diffString, configuration);
document.getElementById("code-block").innerHTML = html;
})
</script>
<div style="margin: 5%;">
<pre id="code-block" style="height: 500px; overflow: scroll;"></pre>
</div>
</body> |
@Riken-Shah After replacing the Unfortunatly I do not have a solution atm for that scenario. Let me know if you have ideas. |
I think it is the same as this issue #185 Add Read more about this at -> https://css-tricks.com/absolute-positioning-inside-relative-positioning/
This mean... |
@ve3 like I said before. If I do that change I always get it broken on horizontal scroll. You really need to provide an example where it is not broken. I cannot replicate the fix. |
I don't see any horizontal scroll broken. https://codepen.io/ve3/pen/LYyOdNQ Checked on Firefox, Chrome. How does it broken? Update: Oh! I see that when H scroll to the right, the line number disappear. Is that? In this case... I try to locate the element with class
to see how is it on GitHub and the result as seen in screenshot. In this case, I see that H scroll on line numbers and limited height inside wrapped element can't go together without additional JS to render special element. |
The example you provided is broken. The line numbers are supposed to always be visible. That only happens due to the change. |
I was updated the example -> https://codepen.io/ve3/pen/LYyOdNQ The code below can help fix horizontal scroll with position relative. // @link https://stackoverflow.com/a/8676457/128761 Fix horizontal scroll.
var leftOffset = parseInt($(".d2h-code-side-linenumber").css('left')); //Grab the left position left first
$('.d2h-file-side-diff').scroll(function(){
$('.d2h-code-side-linenumber').css({
'left': $(this).scrollLeft() + leftOffset //Use it later
});
}); It is not very good result but in case who want to keep both working, this maybe help. |
modify css .d2h-code-side-linenumber {
position: relative;
display: table-cell;
}
.d2h-code-side-line {
padding: 0 0.5em;
} have a try |
@Shimada666 not sure what you were expecting but it does not work. |
@rtfpessoa, Maybe it is a different but related bug. Inserted HTML creates double scrollbars if a parent div is scroll=auto & fixed height. @Shimada666 's CSS fixed this problem for me. |
Yes, the problem we are trying to solve here is to have a limited height, but the HTML and CSS are not ready for this. It would need a re-write to make it work without breaking the current functionality. |
I encounter the same issue. Are there any chance that this will be fixed? Or did you fix this issue on your project @Riken-Shah ? |
@aldifirmansyah, No I also tried but I can't seem to fix it. .d2h-code-side-linenumber{
position: relative;
} As @rtfpessoa said, using this will create another issue,
|
Maybe my sample might help |
Same issue, but to fix just using .d2h-diff-tbody tr {
position: relative;
} |
have a try ,that fixed my problem |
Any updates, that was fixed since ? |
Due to the fixes maybe conflict with stick line numbers. Stick line numbers is default option for this repo. So, I think what if you add some option to do not stick line numbers and use one of our CSS to fix the problem? |
Step -1: Before filling an issue check out troubleshooting section
Step 0: Describe your environment
Step 1: Describe the problem:
When wrapping the HTML coming from
diff2html.html
in fixed-sized div line numbers column seems to be broken.The below screenshot best describes the issue,
Steps to reproduce:
diff example:
Observed Results:
Already explained above.
Expected Results:
Line numbers do not overflow.
Relevant Code:
Overridding the line number position fixes the issue,
The text was updated successfully, but these errors were encountered: