🐛 fix(reactflowUtils.ts): prevent default behavior and stop propagation of keyboard event when pressing Ctrl + Backspace on input value that matches block or ends with a space character to improve user experience

This commit is contained in:
Cristhian Zanforlin Lousa 2023-08-04 16:04:15 -03:00
commit e2f0f2069e

View file

@ -235,7 +235,12 @@ export function addVersionToDuplicates(flow: FlowType, flows: FlowType[]) {
export function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>, inputValue: string | string[] | null, block: string)
{
if (e.ctrlKey && inputValue === block && e.key === "Backspace") {
if (typeof inputValue === "string" && e.ctrlKey && e.key === "Backspace" && (inputValue === block || inputValue?.charAt(inputValue?.length - 1) === ' ')) {
e.preventDefault();
e.stopPropagation();
}
if (e.ctrlKey && e.key === "Backspace" && inputValue === block) {
e.preventDefault();
e.stopPropagation();
}