Skip to content
This repository was archived by the owner on Mar 9, 2025. It is now read-only.

Commit 216caec

Browse files
authored
Merge pull request #700 from trey-wallis/dev
8.2.1
2 parents ed13028 + eabf3fa commit 216caec

File tree

9 files changed

+176
-93
lines changed

9 files changed

+176
-93
lines changed

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"authorUrl": "https://github.com/trey-wallis",
88
"isDesktopOnly": false,
99
"fundingUrl": "https://www.buymeacoffee.com/treywallis",
10-
"version": "8.2.0"
10+
"version": "8.2.1"
1111
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-dataloom",
3-
"version": "8.2.0",
3+
"version": "8.2.1",
44
"description": "Weave together data from diverse sources into a cohesive table view. Inspired by Excel Spreadsheets and Notion.so.",
55
"main": "main.js",
66
"scripts": {

src/react/loom-app/app/hooks/use-row.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import RowAddCommand from "src/shared/loom-state/commands/row-add-command";
44
import RowDeleteCommand from "src/shared/loom-state/commands/row-delete-command";
55
import React from "react";
66
import RowInsertCommand from "src/shared/loom-state/commands/row-insert-command";
7+
import { confirmSortOrderChange } from "src/shared/sort-utils";
78

89
export const useRow = () => {
910
const logger = useLogger();
10-
const { doCommand } = useLoomState();
11+
const { doCommand, loomState } = useLoomState();
1112

1213
const handleRowDeleteClick = React.useCallback(
1314
(rowId: string) => {
@@ -28,14 +29,18 @@ export const useRow = () => {
2829
logger("handleRowInsertAboveClick", {
2930
rowId,
3031
});
31-
doCommand(new RowInsertCommand(rowId, "above"));
32+
if (confirmSortOrderChange(loomState)) {
33+
doCommand(new RowInsertCommand(rowId, "above"));
34+
}
3235
}
3336

3437
function handleRowInsertBelowClick(rowId: string) {
3538
logger("handleRowInsertBelowClick", {
3639
rowId,
3740
});
38-
doCommand(new RowInsertCommand(rowId, "below"));
41+
if (confirmSortOrderChange(loomState)) {
42+
doCommand(new RowInsertCommand(rowId, "below"));
43+
}
3944
}
4045

4146
return {

src/react/loom-app/table/index.tsx

+24-4
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,20 @@ const Components: TableComponents = {
111111
},
112112
//Don't apply styles because we want to apply sticky positioning
113113
//to the cells, not the header container
114-
TableHead: React.forwardRef(({ ...props }, ref) => (
115-
<div className="dataloom-header" {...props} ref={ref} />
116-
)),
114+
TableHead: React.forwardRef(({ ...props }, ref) => {
115+
return (
116+
<div
117+
className="dataloom-header"
118+
{...props}
119+
style={{
120+
position: undefined,
121+
top: undefined,
122+
zIndex: undefined,
123+
}}
124+
ref={ref}
125+
/>
126+
);
127+
}),
117128
TableRow: ({ style, ...props }) => {
118129
return <BodyRow {...props} style={style} />;
119130
},
@@ -123,7 +134,16 @@ const Components: TableComponents = {
123134
//Don't apply styles because we want to apply sticky positioning
124135
//to the cells, not the footer container
125136
TableFoot: React.forwardRef(({ ...props }, ref) => (
126-
<div className="dataloom-footer" {...props} ref={ref} />
137+
<div
138+
className="dataloom-footer"
139+
{...props}
140+
style={{
141+
position: undefined,
142+
bottom: undefined,
143+
zIndex: undefined,
144+
}}
145+
ref={ref}
146+
/>
127147
)),
128148
FillerRow: ({ height }) => {
129149
return <div className="dataloom-row" style={{ height }} />;

src/shared/dragging/utils.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { SortDir, LoomState } from "../loom-state/types";
2+
import { confirmSortOrderChange } from "../sort-utils";
23
import { DragData } from "./types";
34

45
export const getRowId = (rowEl: HTMLElement) => {
@@ -15,26 +16,15 @@ export const getRowId = (rowEl: HTMLElement) => {
1516
export const dropDrag = (
1617
targetRowId: string,
1718
dragData: DragData | null,
18-
LoomState: LoomState,
19+
state: LoomState,
1920
onLoomStateChange: React.Dispatch<React.SetStateAction<LoomState>>
2021
) => {
2122
if (dragData === null) throw Error("No drag data found");
2223

2324
//If we're dragging a column type, then return
2425
if (dragData.type !== "row") return;
2526

26-
const { columns } = LoomState.model;
27-
const isSorted = columns.find((column) => column.sortDir !== SortDir.NONE);
28-
if (isSorted) {
29-
if (
30-
!window.confirm(
31-
"This will set your default sorting to the current sort filter. Do you wish to continue?" +
32-
"\n\n" +
33-
"If not, please remove your sort filter before dragging a row."
34-
)
35-
)
36-
return;
37-
}
27+
if (!confirmSortOrderChange(state)) return;
3828

3929
onLoomStateChange((prevState) => {
4030
const { bodyRows, columns } = prevState.model;

src/shared/loom-state/commands/row-insert-command.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ describe("row-insert-command", () => {
3131
//Assert
3232
expect(executeState.model.bodyRows.length).toEqual(2); //make sure that the row was added
3333
expect(executeState.model.bodyCells.length).toEqual(2);
34-
expect(executeState.model.bodyRows[0].id).toEqual(rowId); //make sure that the row was added above the original row
35-
expect(executeState.model.bodyRows[0].index).toEqual(1);
34+
expect(executeState.model.bodyRows[1].id).toEqual(rowId); //make sure that the row was added above the original row
35+
expect(executeState.model.bodyRows[1].index).toEqual(1);
3636
});
3737

3838
it("should insert a row below when execute() is called", () => {

0 commit comments

Comments
 (0)