Skip to content

Commit

Permalink
fix(app-page-builder): use debounce in updateElementAction inside Tex…
Browse files Browse the repository at this point in the history
…t element
  • Loading branch information
Ashu96 committed Nov 5, 2021
1 parent 86b4460 commit b09fb30
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Expand Up @@ -28,7 +28,8 @@ const PbText: React.FunctionComponent<TextElementProps> = ({
const [activeElementId, setActiveElementAtomValue] = useRecoilState(activeElementAtom);
const { getUpdateValue } = useUpdateHandlers({
element,
dataNamespace: DATA_NAMESPACE
dataNamespace: DATA_NAMESPACE,
debounce: false
});

const fallbackValue = useMemo(
Expand Down
@@ -1,18 +1,20 @@
import { useEventActionHandler } from "../../hooks/useEventActionHandler";
import { UpdateElementActionEvent } from "../../recoil/actions";
import { UpdateElementActionArgsType } from "../../recoil/actions/updateElement/types";
import { PbEditorElement } from "../../../types";
import { useMemo } from "react";
import lodashSet from "lodash/set";
import lodashMerge from "lodash/merge";
import { useHandler } from "@webiny/app/hooks/useHandler";
import { useEventActionHandler } from "~/editor/hooks/useEventActionHandler";
import { UpdateElementActionEvent } from "~/editor/recoil/actions";
import { UpdateElementActionArgsType } from "~/editor/recoil/actions/updateElement/types";
import { SaveRevisionActionArgsType } from "~/editor/recoil/actions/saveRevision/types";
import { PbEditorElement } from "~/types";

export type PostModifyElementArgs = {
name: string;
newValue: any;
element: PbEditorElement;
newElement: PbEditorElement;
};
type UpdateHandlersPropsType = {
type UpdateHandlersPropsType = SaveRevisionActionArgsType & {
element: PbEditorElement;
dataNamespace: string;
postModifyElement?: (args: PostModifyElementArgs) => void;
Expand Down Expand Up @@ -50,7 +52,9 @@ const useUpdateHandlers: UseUpdateHandlersType = props => {
historyUpdated[propName] = newValue;
updateElement({
element: newElement,
history: true
history: true,
debounce: props.debounce,
onFinish: props.onFinish
});
}
};
Expand Down

0 comments on commit b09fb30

Please sign in to comment.