Skip to content

Commit ea2e1ea

Browse files
fix(ui): queue count badge renders when left panel collapsed
1 parent e8aa919 commit ea2e1ea

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

invokeai/frontend/web/src/features/queue/components/QueueCountBadge.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,24 @@ export const QueueCountBadge = memo(({ targetRef }: Props) => {
2828
}
2929

3030
const cb = () => {
31-
const { x, y } = target.getBoundingClientRect();
32-
if (x === 0 || y === 0) {
33-
// If the target is not visible, do not show the badge
31+
// If the parent element is not visible, we do not want to show the badge. This can be tricky to reliably
32+
// determine. The best way I've found is to check the bounding rect of the target and its parent.
33+
const badgeElRect = target.getBoundingClientRect();
34+
const parentElRect = parent.getBoundingClientRect();
35+
if (
36+
badgeElRect.x === 0 ||
37+
badgeElRect.y === 0 ||
38+
badgeElRect.width === 0 ||
39+
badgeElRect.height === 0 ||
40+
parentElRect.x === 0 ||
41+
parentElRect.y === 0 ||
42+
parentElRect.width === 0 ||
43+
parentElRect.height === 0
44+
) {
3445
setBadgePos(null);
3546
return;
3647
}
37-
setBadgePos({ x: `${x - 7}px`, y: `${y - 5}px` });
48+
setBadgePos({ x: `${badgeElRect.x - 7}px`, y: `${badgeElRect.y - 5}px` });
3849
};
3950

4051
const resizeObserver = new ResizeObserver(cb);

0 commit comments

Comments
 (0)