Skip to content
This repository was archived by the owner on Nov 4, 2025. It is now read-only.

Commit 37760fb

Browse files
committed
fix: Not trigger onAlign when result is empty
1 parent 092e70e commit 37760fb

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Align.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,15 @@ const Align: React.RefForwardingComponent<RefAlign, AlignProps> = (
7979
const { activeElement } = document;
8080

8181
// We only align when element is visible
82-
if (element) {
83-
if (element.offsetParent) {
84-
result = alignElement(source, element, align);
85-
}
82+
if (element && element.offsetParent) {
83+
result = alignElement(source, element, align);
8684
} else if (point) {
8785
result = alignPoint(source, point, align);
8886
}
8987

9088
restoreFocus(activeElement, source);
9189

92-
if (onAlign) {
90+
if (onAlign && result) {
9391
onAlign(source, result);
9492
}
9593

0 commit comments

Comments
 (0)