@linzjs/step-ag-grid 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@linzjs/step-ag-grid",
3
3
  "repository": "github:linz/step-ag-grid.git",
4
4
  "license": "MIT",
5
- "version": "2.2.1",
5
+ "version": "2.2.2",
6
6
  "keywords": [
7
7
  "aggrid",
8
8
  "ag-grid",
@@ -3,6 +3,7 @@ import { GridContext } from "../contexts/GridContext";
3
3
  import { GridBaseRow } from "./Grid";
4
4
  import { ControlledMenu } from "../react-menu3";
5
5
  import { GridPopoverContext } from "../contexts/GridPopoverContext";
6
+ import { MenuCloseEvent } from "../react-menu3/types";
6
7
 
7
8
  export interface GridPopoverHookProps<RowType> {
8
9
  className: string | undefined;
@@ -45,7 +46,10 @@ export const useGridPopoverHook = <RowType extends GridBaseRow>(props: GridPopov
45
46
  anchorRef={anchorRef}
46
47
  saveButtonRef={saveButtonRef}
47
48
  menuClassName={"step-ag-grid-react-menu"}
48
- onClose={(event: { reason: string }) => triggerSave(event.reason).then()}
49
+ onClose={(event: MenuCloseEvent) => {
50
+ if (event.reason === "blur") return;
51
+ triggerSave(event.reason).then();
52
+ }}
49
53
  viewScroll={"auto"}
50
54
  dontShrinkIfDirectionIsTop={true}
51
55
  className={props.className}
@@ -1,7 +1,7 @@
1
1
  import "./FormTest.scss";
2
2
 
3
3
  import { useCallback, useState } from "react";
4
- import { LuiTextInput } from "@linzjs/lui";
4
+ import { LuiAlertModal, LuiAlertModalButtons, LuiButton, LuiTextInput } from "@linzjs/lui";
5
5
  import { wait } from "../../utils/util";
6
6
  import { CellEditorCommon, CellParams } from "../../components/GridCell";
7
7
  import { useGridPopoverHook } from "../../components/GridPopoverHook";
@@ -35,19 +35,59 @@ export const FormTest = <RowType extends GridBaseRow>(_props: CellEditorCommon):
35
35
  // Close form
36
36
  return true;
37
37
  }, [nameType, numba, plan, props.selectedRows]);
38
+
39
+ const [showModal, setShowModal] = useState<boolean>(false);
40
+
38
41
  const { popoverWrapper } = useGridPopoverHook({ className: _props.className, save });
39
42
 
40
43
  return popoverWrapper(
41
- <div style={{ display: "flex", flexDirection: "row" }} className={"FormTest Grid-popoverContainer"}>
42
- <div className={"FormTest-textInput"}>
43
- <LuiTextInput label={"Name type"} value={nameType} onChange={(e) => setNameType(e.target.value)} />
44
- </div>
45
- <div className={"FormTest-textInput"}>
46
- <LuiTextInput label={"Number"} value={numba} onChange={(e) => setNumba(e.target.value)} />
47
- </div>
48
- <div className={"FormTest-textInput"}>
49
- <LuiTextInput label={"Plan"} value={plan} onChange={(e) => setPlan(e.target.value)} />
44
+ <>
45
+ {showModal && (
46
+ <LuiAlertModal
47
+ data-testid="WarningAlertWithButtons-modal"
48
+ level="warning"
49
+ // If panel is popped out, append modal to poppped out window DOM, otherwise use default
50
+ //appendToElement={() => (poppedOut && popoutElement) || document.body}
51
+ >
52
+ <h2>Header</h2>
53
+ <p className="WarningAlertWithButtons-new-line">
54
+ This modal was added to help fix a bug where the onBlur for the context menu was prematurely closing the
55
+ editor and therefore this modal.
56
+ </p>
57
+ <LuiAlertModalButtons>
58
+ <LuiButton
59
+ level="secondary"
60
+ onClick={() => {
61
+ setShowModal(false);
62
+ }}
63
+ data-testid="WarningAlertWithButtons-cancel"
64
+ >
65
+ Cancel
66
+ </LuiButton>
67
+
68
+ <LuiButton
69
+ level="primary"
70
+ onClick={() => {
71
+ setShowModal(false);
72
+ }}
73
+ data-testid="WarningAlertWithButtons-ok"
74
+ >
75
+ OK
76
+ </LuiButton>
77
+ </LuiAlertModalButtons>
78
+ </LuiAlertModal>
79
+ )}
80
+ <div style={{ display: "flex", flexDirection: "row" }} className={"FormTest Grid-popoverContainer"}>
81
+ <div className={"FormTest-textInput"}>
82
+ <LuiTextInput label={"Name type"} value={nameType} onChange={(e) => setNameType(e.target.value)} />
83
+ </div>
84
+ <div className={"FormTest-textInput"}>
85
+ <LuiTextInput label={"Number"} value={numba} onChange={(e) => setNumba(e.target.value)} />
86
+ </div>
87
+ <div className={"FormTest-textInput"}>
88
+ <LuiButton onClick={() => setShowModal(true)}>Show Modal</LuiButton>
89
+ </div>
50
90
  </div>
51
- </div>,
91
+ </>,
52
92
  );
53
93
  };