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

teableio / teable / 8536869866

03 Apr 2024 10:05AM CUT coverage: 21.234% (-0.3%) from 21.535%
8536869866

Pull #514

github

web-flow
Merge 91a25d710 into 45ee7ebb3
Pull Request #514: refactor: user and link selector

1394 of 2532 branches covered (55.06%)

27 of 1620 new or added lines in 60 files covered. (1.67%)

4 existing lines in 2 files now uncovered.

14588 of 68702 relevant lines covered (21.23%)

2.02 hits per line

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

0.0
/packages/sdk/src/components/grid-enhancements/editor/GridUserEditor.tsx
1
import type { IUserCellValue } from '@teable/core';
×
2
import type { ForwardRefRenderFunction } from 'react';
×
3
import { useRef, useImperativeHandle, forwardRef } from 'react';
×
4
import type { UserField } from '../../../model';
×
5
import type { IEditorRef } from '../../editor/type';
×
6
import { UserEditorMain } from '../../editor/user';
×
7
import type { IEditorProps } from '../../grid';
×
8
import { useGridPopupPosition } from '../hooks';
×
9
import type { IWrapperEditorProps } from './type';
×
10

×
11
const GridUserEditorBase: ForwardRefRenderFunction<
×
12
  IEditorRef<string>,
×
13
  IWrapperEditorProps & IEditorProps
×
14
> = (props, ref) => {
×
15
  const { field, record, rect, style, isEditing } = props;
×
16
  const { id: fieldId, options } = field as UserField;
×
17
  const cellValue = record.getCellValue(field.id) as IUserCellValue | IUserCellValue[];
×
18

×
19
  const defaultFocusRef = useRef<HTMLInputElement | null>(null);
×
20
  const editorRef = useRef<IEditorRef<IUserCellValue | IUserCellValue[] | undefined>>(null);
×
21

×
22
  useImperativeHandle(ref, () => ({
×
23
    focus: () => (editorRef.current || defaultFocusRef.current)?.focus?.(),
×
24
  }));
×
25

×
26
  const attachStyle = useGridPopupPosition(rect, 340);
×
27
  const onChange = (value?: IUserCellValue | IUserCellValue[]) => {
×
28
    record.updateCell(fieldId, value);
×
29
  };
×
30

×
31
  return (
×
32
    <>
×
33
      {isEditing ? (
×
34
        <UserEditorMain
×
35
          ref={editorRef}
×
36
          style={{
×
37
            ...style,
×
38
            ...attachStyle,
×
39
            height: 'auto',
×
40
            minWidth: 280,
×
41
          }}
×
42
          className="absolute rounded-sm border shadow-sm"
×
43
          value={cellValue}
×
NEW
44
          isMultiple={options.isMultiple}
×
45
          onChange={onChange}
×
46
        />
×
47
      ) : (
×
48
        <input className="size-0 opacity-0" ref={defaultFocusRef} />
×
49
      )}
×
50
    </>
×
51
  );
×
52
};
×
53

×
54
export const GridUserEditor = forwardRef(GridUserEditorBase);
×
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