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

glideapps / glide-data-grid / 7455656024

09 Jan 2024 01:59AM CUT coverage: 92.126% (+5.7%) from 86.42%
7455656024

Pull #810

github

jassmith
Fix jitter with freeze rows. Still inefficient
Pull Request #810: 6.0.0

2722 of 3335 branches covered (0.0%)

16509 of 17920 relevant lines covered (92.13%)

3197.67 hits per line

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

70.77
/packages/core/src/internal/data-grid-overlay-editor/private/markdown-overlay-editor.tsx
1
import * as React from "react";
1✔
2
import MarkdownDiv from "../../markdown-div/markdown-div.js";
1✔
3
import { GrowingEntry } from "../../growing-entry/growing-entry.js";
1✔
4
import { MarkdownOverlayEditorStyle } from "./markdown-overlay-editor-style.js";
1✔
5
import { EditPencil, Checkmark } from "../../../common/utils.js";
1✔
6
import type { MarkdownCell, Rectangle, SelectionRange } from "../../data-grid/data-grid-types.js";
1✔
7

1✔
8
interface Props {
1✔
9
    readonly targetRect: Rectangle;
1✔
10
    readonly onChange: (ev: React.ChangeEvent<HTMLTextAreaElement>) => void;
1✔
11
    readonly forceEditMode: boolean;
1✔
12
    readonly onFinish: (newValue?: MarkdownCell | undefined) => void;
1✔
13
    readonly validatedSelection?: SelectionRange;
1✔
14

1✔
15
    readonly value: MarkdownCell;
1✔
16

1✔
17
    createNode?: (content: string) => DocumentFragment;
1✔
18
}
1✔
19

1✔
20
export const MarkdownOverlayEditor: React.FunctionComponent<Props> = p => {
1✔
21
    const { value, onChange, forceEditMode, createNode, targetRect, onFinish, validatedSelection } = p;
3✔
22

3✔
23
    const markdown = value.data;
3✔
24
    const readonly = value.readonly === true;
3✔
25

3✔
26
    const [editMode, setEditMode] = React.useState<boolean>(markdown === "" || forceEditMode);
3✔
27
    const onEditClick = React.useCallback(() => {
3✔
28
        setEditMode(e => !e);
×
29
    }, []);
3✔
30
    const addLeftPad = markdown ? "gdg-ml-6" : "";
3!
31

3✔
32
    if (editMode) {
3!
33
        return (
×
34
            <MarkdownOverlayEditorStyle targetWidth={targetRect.width - 20}>
×
35
                <GrowingEntry
×
36
                    autoFocus={true}
×
37
                    highlight={false}
×
38
                    validatedSelection={validatedSelection}
×
39
                    value={markdown}
×
40
                    onKeyDown={e => {
×
41
                        if (e.key === "Enter") e.stopPropagation();
×
42
                    }}
×
43
                    onChange={onChange}
×
44
                />
×
45
                <div className={`gdg-edit-icon gdg-checkmark-hover ${addLeftPad}`} onClick={() => onFinish(value)}>
×
46
                    <Checkmark />
×
47
                </div>
×
48
            </MarkdownOverlayEditorStyle>
×
49
        );
×
50
    }
×
51
    return (
3✔
52
        <MarkdownOverlayEditorStyle targetWidth={targetRect.width}>
3✔
53
            <MarkdownDiv contents={markdown} createNode={createNode} />
3✔
54
            {!readonly && (
3✔
55
                <>
3✔
56
                    <div className="spacer" />
3✔
57
                    <div className={`gdg-edit-icon gdg-edit-hover ${addLeftPad}`} onClick={onEditClick}>
3✔
58
                        <EditPencil />
3✔
59
                    </div>
3✔
60
                </>
3✔
61
            )}
3✔
62
            <textarea className="gdg-md-edit-textarea gdg-input" autoFocus={true} />
3✔
63
        </MarkdownOverlayEditorStyle>
3✔
64
    );
3✔
65
};
3✔
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