From 12a09976f22628918c9b4b690f76a977c39c857a Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Thu, 17 Aug 2017 14:47:45 -0500 Subject: [PATCH] Prevent vertical scrollbar on header --- edit/edit.css | 5 ++++- edit/lint.js | 14 +++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/edit/edit.css b/edit/edit.css index e4b9a2cc..53762957 100644 --- a/edit/edit.css +++ b/edit/edit.css @@ -424,6 +424,9 @@ body[data-match-highlight="selection"] .CodeMirror-selection-highlight-scrollbar #help-popup .rules { padding: 0 15px; } +#help-popup .save { + margin-right: 3px; +} /************ lint ************/ #lint { @@ -574,7 +577,7 @@ body[data-match-highlight="selection"] .CodeMirror-selection-highlight-scrollbar margin-bottom: 0; } #lint > div { - max-height: 0; + max-height: 20vh; } #lint.collapsed > div { display: none; diff --git a/edit/lint.js b/edit/lint.js index a1c575bb..e8a17931 100644 --- a/edit/lint.js +++ b/edit/lint.js @@ -144,17 +144,20 @@ function renderLintReport(someBlockChanged) { document.getElementById('issue-count').textContent = issueCount; container.replaceChild(newContent, content); container.style.display = newContent.children.length ? 'block' : 'none'; - resizeLintReport(null, newContent); + resizeLintReport(); } } -function resizeLintReport(event, content) { - content = content || document.getElementById('lint').children[1]; +function resizeLintReport() { + const magicBuffer = 20; // subtracted value to prevent scrollbar + const content = $('#lint table'); if (content.children.length) { const bounds = content.getBoundingClientRect(); - const newMaxHeight = bounds.bottom <= innerHeight ? '' : (innerHeight - bounds.top) + 'px'; + const newMaxHeight = bounds.bottom <= window.innerHeight ? '' : + // subtract out a bit of padding or the vertical scrollbar extends beyond the viewport + (window.innerHeight - bounds.top - magicBuffer) + 'px'; if (newMaxHeight !== content.style.maxHeight) { - content.style.maxHeight = newMaxHeight; + content.parentNode.style.maxHeight = newMaxHeight; } } } @@ -189,6 +192,7 @@ function showLintHelp() { const rules = []; const url = 'https://stylelint.io/user-guide/rules/'; header = t('issuesHelp', `stylelint`); + // to-do: change this to a generator $$('#lint td[role="severity"]').forEach(el => { const rule = el.title.replace('Rule: (', '').replace(/[()]/g, '').trim(); if (!rules.includes(rule)) {