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

glideapps / glide-data-grid / 7028070260

29 Nov 2023 04:34AM UTC coverage: 91.033% (+4.6%) from 86.42%
7028070260

Pull #810

github

jassmith
5.99.9-alpha5
Pull Request #810: 6.0.0

2458 of 3061 branches covered (0.0%)

1024 of 1167 new or added lines in 54 files covered. (87.75%)

286 existing lines in 12 files now uncovered.

15066 of 16550 relevant lines covered (91.03%)

2907.47 hits per line

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

97.01
/packages/core/src/data-editor/group-rename.tsx
1
import React from "react";
1✔
2
import { styled } from "@linaria/react";
1✔
3
import { css } from "@linaria/core";
1✔
4
import ClickOutsideContainer from "../internal/click-outside-container/click-outside-container.js";
1✔
5
import type { Rectangle } from "../internal/data-grid/data-grid-types.js";
1✔
6

1✔
7
interface Props {
1✔
8
    readonly bounds: Rectangle;
1✔
9
    readonly group: string;
1✔
10
    readonly onClose: () => void;
1✔
11
    readonly onFinish: (newVal: string) => void;
1✔
12
    readonly canvasBounds: DOMRect;
1✔
13
}
1✔
14

1✔
15
const RenameInput = styled.input<{ targetHeight: number }>`
1✔
16
    flex-grow: 1;
1✔
17
    border: none;
1✔
18
    outline: none;
1✔
19
    background-color: var(--gdg-bg-header-has-focus);
1✔
20
    border-radius: 9px;
1✔
21
    padding: 0 8px;
1✔
22
    box-shadow: 0 0 0 1px var(--gdg-border-color);
1✔
23
    color: var(--gdg-text-group-header);
1✔
24
    min-height: ${p => Math.max(16, p.targetHeight - 10)}px;
1✔
25
    font: var(--gdg-header-font-style) var(--gdg-font-family);
1✔
26
`;
1✔
27

1✔
28
export const GroupRename: React.VFC<Props> = p => {
1✔
29
    const { bounds, group, onClose, canvasBounds, onFinish } = p;
3✔
30

3✔
31
    const [value, setValue] = React.useState(group);
3✔
32

3✔
33
    return (
3✔
34
        <ClickOutsideContainer
3✔
35
            style={{
3✔
36
                position: "absolute",
3✔
37
                left: bounds.x - canvasBounds.left + 1,
3✔
38
                top: bounds.y - canvasBounds.top,
3✔
39
                width: bounds.width - 2,
3✔
40
                height: bounds.height,
3✔
41
            }}
3✔
42
            className={css`
3✔
43
                padding: 0 8px;
3✔
44
                display: flex;
3✔
45
                align-items: center;
3✔
46
                background-color: var(--gdg-bg-header);
3✔
47
            `}
3✔
48
            onClickOutside={onClose}>
3✔
49
            <RenameInput
3✔
50
                targetHeight={bounds.height}
3✔
51
                data-testid="group-rename-input"
3✔
52
                value={value}
3✔
53
                onBlur={onClose}
3✔
54
                onFocus={e => e.target.setSelectionRange(0, value.length)}
3✔
55
                onChange={e => setValue(e.target.value)}
3✔
56
                onKeyDown={e => {
3✔
57
                    if (e.key === "Enter") {
1✔
58
                        onFinish(value);
1✔
59
                    } else if (e.key === "Escape") {
1!
60
                        onClose();
×
UNCOV
61
                    }
×
62
                }}
1✔
63
                autoFocus={true}
3✔
64
            />
3✔
65
        </ClickOutsideContainer>
3✔
66
    );
3✔
67
};
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