Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jassmith committed Feb 15, 2022
2 parents 08387da + 974defa commit 260ec8f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -21,3 +21,7 @@ npm run i && npm run storybook
## Forking the data grid?

Please consider submitting your work for review. We are a small project but we are super enthused when anyone comes by to help us build the best damned data grid on the internet.

## Any contributions you make will be under the MIT Software License

In short, when you submit code changes, your submissions are understood to be under the same MIT License that covers the project. Feel free to contact the maintainers if that's a concern.
Expand Up @@ -529,7 +529,7 @@ export const Overscroll: React.VFC<OverscrollProps> = p => {
description={
<>
<Description>
You can allocate extra space at the ends of the grid by seting the{" "}
You can allocate extra space at the ends of the grid by setting the{" "}
<PropName>overscrollX</PropName> and <PropName>overscrollY</PropName> props
</Description>
</>
Expand Down
26 changes: 26 additions & 0 deletions packages/core/src/data-editor/data-editor.test.tsx
Expand Up @@ -363,6 +363,32 @@ describe("data-editor", () => {
expect(spy).toHaveBeenCalledWith([1, 1], expect.anything());
});

test("Emits finished editing", async () => {
const spy = jest.fn();
jest.useFakeTimers();
render(<DataEditor {...basicProps} onFinishedEditing={spy} />, {
wrapper: Context,
});
prep();
const canvas = screen.getByTestId("data-grid-canvas");
fireEvent.mouseDown(canvas, {
clientX: 300, // Col B
clientY: 36 + 32 + 16, // Row 1 (0 indexed)
});

fireEvent.keyDown(canvas, {
keyCode: 74,
});

const overlay = screen.getByDisplayValue("j");

fireEvent.keyDown(overlay, {
key: "Enter",
});

expect(spy).toBeCalledWith({ allowOverlay: true, data: "j", displayData: "1, 1", kind: "text" }, [0, 1]);
});

test("Emits header click", async () => {
const spy = jest.fn();

Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/data-editor/data-editor.tsx
Expand Up @@ -97,7 +97,7 @@ export interface DataEditorProps extends Props {
readonly onGroupHeaderClicked?: (colIndex: number, event: GroupHeaderClickedEventArgs) => void;
readonly onGroupHeaderRenamed?: (groupName: string, newVal: string) => void;
readonly onCellClicked?: (cell: readonly [number, number], event: CellClickedEventArgs) => void;

readonly onFinishedEditing?: (newValue: GridCell | undefined, movement: readonly [number, number]) => void;
readonly onHeaderContextMenu?: (colIndex: number, event: HeaderClickedEventArgs) => void;
readonly onGroupHeaderContextMenu?: (colIndex: number, event: GroupHeaderClickedEventArgs) => void;
readonly onCellContextMenu?: (cell: readonly [number, number], event: CellClickedEventArgs) => void;
Expand Down Expand Up @@ -207,6 +207,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
rows,
getCellContent,
onCellClicked,
onFinishedEditing,
onHeaderClicked,
onGroupHeaderClicked,
onCellContextMenu,
Expand Down Expand Up @@ -1163,8 +1164,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
const isEditingTrailingRow = gridSelection.cell[1] === mangledRows - 1 && newValue !== undefined;
updateSelectedCell(gridSelection.cell[0] + movX, gridSelection.cell[1] + movY, isEditingTrailingRow);
}
onFinishedEditing?.(newValue, movement);
},
[overlay?.cell, focus, gridSelection, mangledOnCellEdited, mangledRows, updateSelectedCell]
[overlay?.cell, focus, gridSelection, onFinishedEditing, mangledOnCellEdited, mangledRows, updateSelectedCell]
);

const [selCol, selRow] = gridSelection?.cell ?? [];
Expand Down

0 comments on commit 260ec8f

Please sign in to comment.