Skip to content

Commit

Permalink
Merge pull request #291 from hw-df/fix-lineheight
Browse files Browse the repository at this point in the history
Fix gap of upward opening dynamically created contextmenu
  • Loading branch information
jonataswalker authored Oct 14, 2024
2 parents d80615e + e922d7f commit e5037a4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/helpers/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export function getLineHeight(container: HTMLDivElement): number {
cloned.append(element2);
container.parentNode?.append(cloned);

const height = cloned.offsetHeight / 2;
const clonedStyle = window.getComputedStyle(cloned);
const paddingTop = Number.parseInt(clonedStyle.paddingTop, 10);
const paddingBottom = Number.parseInt(clonedStyle.paddingBottom, 10);

const height = (cloned.offsetHeight - (paddingTop + paddingBottom)) / 2;

container.parentNode?.removeChild(cloned);

Expand Down

0 comments on commit e5037a4

Please sign in to comment.