File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
invokeai/frontend/web/src/features/queue/components Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments