diff --git a/package.json b/package.json index 1d8b64c0..a422b64a 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,10 @@ "@emotion/styled": "^11.8.1", "@mdi/js": "^6.6.96", "@monaco-editor/react": "^4.4.4", - "@mui/icons-material": "^5.6.0", + "@mui/icons-material": "^5.8.2", "@mui/lab": "^5.0.0-alpha.76", - "@mui/material": "^5.6.0", - "@mui/styles": "^5.6.2", + "@mui/material": "^5.8.2", + "@mui/styles": "^5.8.0", "@mui/x-date-pickers": "^5.0.0-alpha.4", "@rowy/form-builder": "^0.6.1", "@rowy/multiselect": "^0.4.0", diff --git a/src/atoms/tableScope/rowActions.ts b/src/atoms/tableScope/rowActions.ts index 3cb88605..9d197b17 100644 --- a/src/atoms/tableScope/rowActions.ts +++ b/src/atoms/tableScope/rowActions.ts @@ -1,5 +1,12 @@ import { atom } from "jotai"; -import { cloneDeep, find, set as _set, unset } from "lodash-es"; +import { + cloneDeep, + find, + get as _get, + set as _set, + isEqual, + unset, +} from "lodash-es"; import { currentUserAtom } from "@src/atoms/globalScope"; import { @@ -211,6 +218,8 @@ export interface IUpdateFieldOptions { deleteField?: boolean; /** If true, ignores checking required fields have values */ ignoreRequiredFields?: boolean; + /** Optionally, disable checking if the updated value is equal to the current value. By default, we skip the update if they’re equal. */ + disableCheckEquality?: boolean; } /** * Updates or deletes a field in a row. @@ -235,6 +244,7 @@ export const updateFieldAtom = atom( value, deleteField, ignoreRequiredFields, + disableCheckEquality, }: IUpdateFieldOptions ) => { const updateRowDb = get(_updateRowDbAtom); @@ -271,7 +281,15 @@ export const updateFieldAtom = atom( : requiredFields.filter((field) => row[field] === undefined); // Apply field update - if (!deleteField) _set(update, fieldName, value); + if (!deleteField) { + // Check for equality. If updated value is same as current, skip update + if (!disableCheckEquality) { + const currentValue = _get(row, fieldName); + if (isEqual(currentValue, value)) return; + } + // Otherwise, apply the update + _set(update, fieldName, value); + } // Update rowsLocal if any required fields are missing if (missingRequiredFields.length > 0) { diff --git a/src/components/CodeEditor/CodeEditor.tsx b/src/components/CodeEditor/CodeEditor.tsx index 2914bef5..39e05c57 100644 --- a/src/components/CodeEditor/CodeEditor.tsx +++ b/src/components/CodeEditor/CodeEditor.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import Editor, { EditorProps } from "@monaco-editor/react"; import type { editor } from "monaco-editor/esm/vs/editor/editor.api"; -import { useTheme, Box, BoxProps } from "@mui/material"; +import { useTheme, Box, BoxProps, AppBar, Toolbar } from "@mui/material"; import TrapFocus from "@mui/material/Unstable_TrapFocus"; import CircularProgressOptical from "@src/components/CircularProgressOptical"; import { ResizeBottomRight } from "@src/assets/icons"; @@ -17,12 +17,15 @@ export interface ICodeEditorProps Omit { value: string; containerProps?: Partial; + fullScreenTitle?: React.ReactNode; onValidate?: EditorProps["onValidate"]; onValidStatusUpdate?: (result: { isValid: boolean; markers: editor.IMarker[]; }) => void; + onFocus?: () => void; + onBlur?: () => void; } export default function CodeEditor({ @@ -31,9 +34,12 @@ export default function CodeEditor({ disabled, error, containerProps, + fullScreenTitle, onValidate, onValidStatusUpdate, + onFocus, + onBlur, extraLibs, diagnosticsOptions, @@ -76,11 +82,22 @@ export default function CodeEditor({ ]} style={fullScreen ? { height: "100%" } : {}} > + {fullScreen && fullScreenTitle && ( + + + {fullScreenTitle} + + + )} } className="editor" + onMount={(editor) => { + if (onFocus) editor.onDidFocusEditorWidget(onFocus); + if (onBlur) editor.onDidBlurEditorWidget(onBlur); + }} {...props} onValidate={onValidate_} options={{ diff --git a/src/components/CodeEditor/useMonacoCustomizations.ts b/src/components/CodeEditor/useMonacoCustomizations.ts index aae7fa9c..8c83558a 100644 --- a/src/components/CodeEditor/useMonacoCustomizations.ts +++ b/src/components/CodeEditor/useMonacoCustomizations.ts @@ -314,7 +314,7 @@ export default function useMonacoCustomizations({ left: 0, right: 0, bottom: 0, - zIndex: theme.zIndex.tooltip + 1, + zIndex: theme.zIndex.tooltip * 2, m: "0 !important", resize: "none", backgroundColor: theme.palette.background.paper, diff --git a/src/components/ErrorFallback.tsx b/src/components/ErrorFallback.tsx index 40494a0b..d477f4fb 100644 --- a/src/components/ErrorFallback.tsx +++ b/src/components/ErrorFallback.tsx @@ -42,6 +42,7 @@ export default function ErrorFallback({ {error.message}