Skip to content

Commit 5154c70

Browse files
Improve compatibility with external CSS that includes overflow and background/color rules on pre, in core and autocomplete plugin (Fixes #198)
Co-authored-by: figuerom16 <112363116+figuerom16@users.noreply.github.com>
1 parent 7c425f6 commit 5154c70

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

code-input.css

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,32 +61,34 @@ code-input textarea, code-input:not(.code-input_pre-element-styled) pre code, co
6161
padding-right: var(--padding-right, 16px)!important;
6262
padding-top: var(--padding-top, 16px)!important;
6363
padding-bottom: var(--padding-bottom, 16px)!important;
64-
border: 0;
64+
6565
min-width: calc(100% - var(--padding-left, 16px) - var(--padding-right, 16px));
6666
min-height: calc(100% - var(--padding-top, 16px) - var(--padding-bottom, 16px));
67-
overflow: hidden;
6867
resize: none;
6968
grid-row: 1;
7069
grid-column: 1;
7170
display: block;
72-
}
73-
74-
code-input:not(.code-input_pre-element-styled) pre code, code-input.code-input_pre-element-styled pre {
75-
height: max-content;
76-
width: max-content;
77-
7871

7972
/* Allow colour change to reflect properly;
8073
transition-behavior: allow-discrete could be used but this is better supported and
8174
works with the color property. */
8275
transition: color 0.001s;
8376
}
77+
code-input textarea, code-input:not(.code-input_pre-element-styled) pre code, code-input pre {
78+
border: 0;
79+
80+
height: max-content;
81+
width: max-content;
82+
}
8483

8584
code-input:not(.code-input_pre-element-styled) pre, code-input.code-input_pre-element-styled pre code {
8685
/* Remove all margin and padding from others */
8786
margin: 0!important;
8887
padding: 0!important;
8988
border: 0!important;
89+
90+
min-width: 100%;
91+
min-height: 100%;
9092
}
9193

9294
code-input textarea, code-input pre, code-input pre * {
@@ -97,6 +99,9 @@ code-input textarea, code-input pre, code-input pre * {
9799
tab-size: inherit!important;
98100
text-align: inherit!important;
99101
}
102+
code-input textarea, code-input pre, code-input pre code {
103+
overflow: visible!important;
104+
}
100105

101106
/* Make changing the text direction propogate */
102107
code-input textarea[dir=auto] + pre {

plugins/autocomplete.css

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ code-input .code-input_autocomplete_popup {
99
z-index: 100;
1010
}
1111

12-
13-
code-input .code-input_autocomplete_testpos {
14-
opacity: 0;
15-
}
12+
code-input pre.code-input_autocomplete_invisiblepre {
13+
opacity: 0!important;
14+
}

plugins/autocomplete.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ codeInput.plugins.Autocomplete = class extends codeInput.Plugin {
3232
codeInput.appendChild(popupElem);
3333

3434
let testPosPre = document.createElement("pre");
35+
testPosPre.classList.add("code-input_autocomplete_invisiblepre"); // Hide visually
3536
testPosPre.setAttribute("aria-hidden", true); // Hide for screen readers
3637
if(codeInput.templateObject.preElementStyled) {
3738
testPosPre.classList.add("code-input_autocomplete_testpos");

0 commit comments

Comments
 (0)