Skip to content

Commit 7d5c797

Browse files
committed
fix: scroll issues
1 parent f053b92 commit 7d5c797

6 files changed

Lines changed: 32 additions & 18 deletions

File tree

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@
2222
"[svelte]": {
2323
"editor.defaultFormatter": "svelte.svelte-vscode"
2424
},
25+
"[scss]": {
26+
"editor.defaultFormatter": "esbenp.prettier-vscode"
27+
},
2528
"css.customData": [".vscode/tailwind.json"]
2629
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div class="discord-plus-icon">
2-
<iconify-icon icon="radix-icons:plus-circled" class="text-2xl"></iconify-icon>
2+
<iconify-icon icon="icons8:plus" class="text-2xl"></iconify-icon>
33
</div>

docs/src/lib/styles/discord.scss

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@
1414

1515
.carta-wrapper {
1616
padding: 1rem;
17-
padding-left: 56px;
1817
flex-grow: 1;
19-
overflow-y: auto;
18+
}
19+
20+
.carta-input-wrapper {
21+
padding-left: 36px;
22+
}
2023

21-
.carta-container {
22-
min-height: 32px;
23-
max-height: 400px;
24-
}
24+
.carta-input,
25+
.carta-renderer {
26+
min-height: 32px;
27+
max-height: 400px;
28+
overflow: auto;
2529
}
2630

2731
.carta-font-code {
@@ -37,7 +41,7 @@
3741
.discord-plus-icon {
3842
position: absolute;
3943
top: 15px;
40-
left: -24px;
44+
left: 15px;
4145
width: 1.75rem;
4246
height: 1.75rem;
4347
transform: translateX(-50%) translateY(-50%);

docs/src/lib/styles/github.scss

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
.carta-wrapper {
1818
padding: 1rem;
1919
flex-grow: 1;
20-
overflow-y: auto;
20+
}
2121

22-
.carta-container {
23-
min-height: 120px;
24-
max-height: 160px;
25-
}
22+
.carta-input,
23+
.carta-renderer {
24+
min-height: 120px;
25+
max-height: 160px;
26+
overflow: auto;
2627
}
2728

2829
.carta-font-code {

docs/src/lib/styles/math-stack-exchange.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
&:focus-within {
2626
outline: 3px solid rgba($accent, 0.5);
2727
}
28+
}
2829

29-
.carta-container {
30-
height: 200px;
31-
}
30+
.carta-input,
31+
.carta-renderer {
32+
height: 200px;
33+
overflow: auto;
3234
}
3335

3436
.carta-font-code {

packages/carta-md/src/lib/internal/components/Input.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@
4949
textarea.style.height = textarea.scrollHeight + 'px';
5050
textarea.scrollTop = 0;
5151
52+
const isFocused = document.activeElement === textarea;
53+
if (!isFocused) return;
5254
const coords = carta.input?.getCursorXY();
53-
elem.scrollTo({ top: coords?.top, behavior: 'instant' });
55+
if (!coords) return;
56+
57+
if (coords.top < 0 || coords.top >= elem.scrollTop + elem.clientHeight)
58+
elem.scrollTo({ top: coords?.top, behavior: 'instant' });
5459
};
5560
5661
const focus = () => {
@@ -188,7 +193,6 @@
188193
}
189194
190195
.carta-input-wrapper {
191-
height: 100%;
192196
position: relative;
193197
font-family: monospace;
194198
}

0 commit comments

Comments
 (0)