Skip to content

Commit

Permalink
fix(MarkdownEditor): wrong scrolltop calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
BearToCode committed Jul 27, 2024
1 parent 7d5c797 commit c59f171
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/carta-md/src/lib/internal/components/Input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@
const isFocused = document.activeElement === textarea;
if (!isFocused) return;
const coords = carta.input?.getCursorXY();
if (!carta.input) return;
const coords = carta.input.getCursorXY();
if (!coords) return;
if (coords.top < 0 || coords.top >= elem.scrollTop + elem.clientHeight)
if (
coords.top < 0 ||
coords.top + carta.input.getRowHeight() >= elem.scrollTop + elem.clientHeight
)
elem.scrollTo({ top: coords?.top, behavior: 'instant' });
};
Expand Down

0 comments on commit c59f171

Please sign in to comment.