Skip to content

Commit 79b79e0

Browse files
committed
fix(caret): incorrect underline positioning
1 parent 5526088 commit 79b79e0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

frontend/src/styles/caret.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,5 @@
7272
&.underline {
7373
height: 0.1em;
7474
width: 0.5em;
75-
margin-top: 1.2em;
7675
}
7776
}

frontend/src/ts/utils/caret.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,15 @@ export class Caret {
519519
top += options.letter.offsetTop;
520520
top += options.word.offsetTop;
521521

522-
// center the caret vertically and horizontally
523-
if (this.style !== "underline") {
522+
if (this.style === "underline") {
523+
// if style is underline, add the height of the letter to the top
524+
top += options.letter.offsetHeight;
525+
} else {
526+
// else center vertically in the letter
524527
top += (options.letter.offsetHeight - this.getHeight()) / 2;
525528
}
529+
530+
// also center horizontally
526531
if (!this.isFullWidth()) {
527532
left += (this.getWidth() / 2) * -1;
528533
}

0 commit comments

Comments
 (0)