• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

glideapps / glide-data-grid / 7333166280

26 Dec 2023 10:45PM UTC coverage: 90.585% (+4.2%) from 86.42%
7333166280

Pull #810

github

jassmith
5.99.9-charlie1
Pull Request #810: 6.0.0

2594 of 3246 branches covered (0.0%)

3363 of 3831 new or added lines in 62 files covered. (87.78%)

265 existing lines in 12 files now uncovered.

15759 of 17397 relevant lines covered (90.58%)

3076.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.72
/packages/core/src/common/resize-detector.ts
1
/* eslint-disable @typescript-eslint/strict-boolean-expressions */
1✔
2
import { useLayoutEffect, useState, useRef, type MutableRefObject } from "react";
1✔
3
interface ReactResizeDetectorDimensions {
1✔
4
    height?: number;
1✔
5
    width?: number;
1✔
6
}
1✔
7

1✔
8
export function useResizeDetector<T extends HTMLElement = HTMLElement>(
1✔
9
    initialSize?: readonly [width: number, height: number]
1✔
10
): UseResizeDetectorReturn<T> {
1✔
11
    const ref = useRef<T>(null);
1✔
12

1✔
13
    const [size, setSize] = useState<ReactResizeDetectorDimensions>({
1✔
14
        width: initialSize?.[0],
1!
15
        height: initialSize?.[1],
1!
16
    });
1✔
17

1✔
18
    useLayoutEffect(() => {
1✔
19
        const resizeCallback: ResizeObserverCallback = entries => {
1✔
UNCOV
20
            for (const entry of entries) {
×
21
                const { width, height } = (entry && entry.contentRect) || {};
×
22
                setSize(cv => (cv.width === width && cv.height === height ? cv : { width, height }));
×
UNCOV
23
            }
×
UNCOV
24
        };
×
25

1✔
26
        const resizeObserver = new window.ResizeObserver(resizeCallback);
1✔
27

1✔
28
        if (ref.current) {
1!
29
            resizeObserver.observe(ref.current, undefined);
×
UNCOV
30
        }
×
31

1✔
32
        return () => {
1✔
33
            resizeObserver.disconnect();
1✔
34
        };
1✔
35
        // eslint-disable-next-line react-hooks/exhaustive-deps
1✔
36
    }, [ref.current]);
1✔
37

1✔
38
    return { ref, ...size };
1✔
39
}
1✔
40

1✔
41
export interface UseResizeDetectorReturn<T> extends ReactResizeDetectorDimensions {
1✔
42
    ref: MutableRefObject<T | null>;
1✔
43
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc