Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/visualBuilder/utils/handleIndividualFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { VisualBuilderPostMessageEvents } from "./types/postMessage.types";
import { updateFocussedState } from "./updateFocussedState";
import { FieldDataType } from "./types/index.types";
import { getMultilinePlaintext } from "./getMultilinePlaintext";
import { addFocusOverlay } from "../generators/generateOverlay";

/**
* It handles all the fields based on their data type and its "multiple" property.
Expand Down Expand Up @@ -184,6 +185,23 @@ export async function handleIndividualFields(
} else if (elementComputedDisplay === "inline") {
// if the editable field is inline
const onInlineElementInput = throttle(() => {
const overlayWrapper = visualBuilderContainer.querySelector(
".visual-builder__overlay__wrapper"
) as HTMLDivElement;
const previousSelectedEditableDOM =
VisualBuilder.VisualBuilderGlobalState.value
.previousSelectedEditableDOM;
if(!previousSelectedEditableDOM){
return
}
addFocusOverlay(previousSelectedEditableDOM, overlayWrapper);
}, 200);
actualEditableField.addEventListener(
"input",
onInlineElementInput
);

const updateFocussedStateOnInput = debounce(() => {
const overlayWrapper = visualBuilderContainer.querySelector(
".visual-builder__overlay__wrapper"
) as HTMLDivElement;
Expand All @@ -197,10 +215,10 @@ export async function handleIndividualFields(
resizeObserver,
focusedToolbar,
});
}, 200);
}, 800);
actualEditableField.addEventListener(
"input",
onInlineElementInput
updateFocussedStateOnInput
);
}

Expand Down
Loading