Closed
Description
Describe the bug
If you give the item-container element a vertical margin, the drag line position is calculated incorrectly.
To Reproduce
Give item-container a vertical margin like so:
.rct-tree-item-title-container {
margin-top: 2px;
margin-bottom: 2px;
}
2024-07-25.21-27-25_edited.mp4
Additional context
The issue is that it is calculating the item container's height incorrectly:
It uses
.offsetHeight
, which doesn't take into account margins. The following patch worked for me:
const firstItem = getDocument()?.querySelector(
`[data-rct-tree="${treeId}"] [data-rct-item-container="true"]`
);
if (firstItem) {
const style = getComputedStyle(firstItem);
// note: divide total margin by two
// when two item containers are adjacent and both have margins, only one margin is rendered
return firstItem.offsetHeight + (parseFloat(style.marginBottom) + parseFloat(style.marginTop)) / 2;
} else {
return 5;
}
Metadata
Metadata
Assignees
Labels
No labels