Skip to content

Commit e5037a4

Browse files
Merge pull request #291 from hw-df/fix-lineheight
Fix gap of upward opening dynamically created contextmenu
2 parents d80615e + e922d7f commit e5037a4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/helpers/dom.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ export function getLineHeight(container: HTMLDivElement): number {
3434
cloned.append(element2);
3535
container.parentNode?.append(cloned);
3636

37-
const height = cloned.offsetHeight / 2;
37+
const clonedStyle = window.getComputedStyle(cloned);
38+
const paddingTop = Number.parseInt(clonedStyle.paddingTop, 10);
39+
const paddingBottom = Number.parseInt(clonedStyle.paddingBottom, 10);
40+
41+
const height = (cloned.offsetHeight - (paddingTop + paddingBottom)) / 2;
3842

3943
container.parentNode?.removeChild(cloned);
4044

0 commit comments

Comments
 (0)