Skip to content

Commit

Permalink
update useEditableText.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
chuchee authored and keikeicheung committed Nov 4, 2024
1 parent fee9e31 commit 8145c4e
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions vuu-ui/packages/vuu-ui-controls/src/editable/useEditableText.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { DataValueValidationChecker } from "@finos/vuu-data-types";
import { DataItemEditHandler } from "@finos/vuu-table-types";
import { getTypedValue } from "@finos/vuu-utils";
import { VuuRowDataItemType } from "@finos/vuu-protocol-types";
import { dispatchCustomEvent } from "@finos/vuu-utils";
import { DataItemEditHandler } from "@finos/vuu-table-types";
import { dispatchCustomEvent, getTypedValue } from "@finos/vuu-utils";
import {
FocusEventHandler,
FormEventHandler,
KeyboardEvent,
useCallback,
useMemo,
useRef,
useState,
} from "react";
Expand Down Expand Up @@ -37,16 +35,16 @@ export const useEditableText = <T extends string | number | boolean = string>({
const [editState, setEditState] = useState<EditState>({
value: value?.toString() ?? "",
});
console.log("edit state: ", editState);
// console.log("edit state: ", editState);
const initialValueRef = useRef<string>(value?.toString() ?? "");
const isDirtyRef = useRef(false);

useMemo(() => {
if (editState.value !== value?.toString()) {
setEditState({ message: "", value: value?.toString() ?? "" });
console.log("initial value changed to: ", value);
}
}, [editState.value, value]);
// useMemo(() => {
// if (editState.value !== value?.toString()) {
// setEditState({ message: "", value: value?.toString() ?? "" });
// console.log("initial value changed to: ", value);
// }
// }, [editState.value, value]);

const commit = useCallback(
async (target: HTMLElement) => {
Expand Down

0 comments on commit 8145c4e

Please sign in to comment.