🐛 fix(App.tsx): prevent default behavior of Ctrl+Backspace key combination to improve user experience
🐛 fix(AccordionComponent/index.tsx): prevent default behavior of Backspace key to improve user experience 🐛 fix(floatComponent/index.tsx): prevent default behavior of Backspace key to improve user experience 🐛 fix(inputComponent/index.tsx): prevent default behavior of Backspace key to improve user experience 🐛 fix(inputListComponent/index.tsx): prevent default behavior of Ctrl+Backspace key combination to improve user experience 🐛 fix(intComponent/index.tsx): prevent default behavior of Backspace key to improve user experience 🐛 fix(genericModal/index.tsx): prevent default behavior of Backspace key to improve user experience
This commit is contained in:
parent
3a76d2de59
commit
2f1f3ee9d8
8 changed files with 60 additions and 0 deletions
|
|
@ -121,6 +121,20 @@ export default function App() {
|
|||
);
|
||||
};
|
||||
|
||||
const handleKeyPress = (e: KeyboardEvent) => {
|
||||
if (e.ctrlKey && e.key === "Backspace") {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
document.addEventListener('keydown', handleKeyPress);
|
||||
return () => {
|
||||
document.removeEventListener('keydown', handleKeyPress);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
//need parent component with width and height
|
||||
<div className="flex h-full flex-col">
|
||||
|
|
|
|||
|
|
@ -32,6 +32,13 @@ export default function AccordionComponent({
|
|||
value === "" ? setValue(keyValue) : setValue("");
|
||||
}
|
||||
|
||||
const handleKeyDown = (event) => {
|
||||
if (event.key === "Backspace") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Accordion
|
||||
|
|
@ -39,6 +46,7 @@ export default function AccordionComponent({
|
|||
className="w-full"
|
||||
value={value}
|
||||
onValueChange={setValue}
|
||||
onKeyDown={handleKeyDown}
|
||||
>
|
||||
<AccordionItem value={keyValue} className="border-b">
|
||||
<AccordionTrigger
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { useEffect } from "react";
|
||||
import { FloatComponentType } from "../../types/components";
|
||||
import { Input } from "../ui/input";
|
||||
import { handleKeyDown } from "../../utils/reactflowUtils";
|
||||
|
||||
export default function FloatComponent({
|
||||
value,
|
||||
|
|
@ -43,6 +44,9 @@ export default function FloatComponent({
|
|||
onChange={(e) => {
|
||||
onChange(e.target.value);
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
handleKeyDown(e, value, '0');
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
|
|||
import { InputComponentType } from "../../types/components";
|
||||
import { classNames } from "../../utils/utils";
|
||||
import { Input } from "../ui/input";
|
||||
import { handleKeyDown } from "../../utils/reactflowUtils";
|
||||
|
||||
export default function InputComponent({
|
||||
value,
|
||||
|
|
@ -19,6 +20,7 @@ export default function InputComponent({
|
|||
}
|
||||
}, [disabled, onChange]);
|
||||
|
||||
|
||||
return (
|
||||
<div className="relative w-full">
|
||||
<Input
|
||||
|
|
@ -34,6 +36,9 @@ export default function InputComponent({
|
|||
onChange={(e) => {
|
||||
onChange(e.target.value);
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
handleKeyDown(e, value, '');
|
||||
}}
|
||||
/>
|
||||
{password && (
|
||||
<button
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import _ from "lodash";
|
|||
import { classNames } from "../../utils/utils";
|
||||
import IconComponent from "../genericIconComponent";
|
||||
import { Input } from "../ui/input";
|
||||
import { handleKeyDown } from "../../utils/reactflowUtils";
|
||||
|
||||
export default function InputListComponent({
|
||||
value,
|
||||
|
|
@ -39,6 +40,12 @@ export default function InputListComponent({
|
|||
newInputList[idx] = e.target.value;
|
||||
onChange(newInputList);
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.ctrlKey && e.key === "Backspace") {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{idx === value.length - 1 ? (
|
||||
<button
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { useEffect } from "react";
|
||||
import { FloatComponentType } from "../../types/components";
|
||||
import { Input } from "../ui/input";
|
||||
import { handleKeyDown } from "../../utils/reactflowUtils";
|
||||
|
||||
export default function IntComponent({
|
||||
value,
|
||||
|
|
@ -17,6 +18,8 @@ export default function IntComponent({
|
|||
}
|
||||
}, [disabled, onChange]);
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<div className="w-full">
|
||||
<Input
|
||||
|
|
@ -37,6 +40,7 @@ export default function IntComponent({
|
|||
) {
|
||||
event.preventDefault();
|
||||
}
|
||||
handleKeyDown(event, value, '0');
|
||||
}}
|
||||
type="number"
|
||||
step="1"
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import {
|
|||
varHighlightHTML,
|
||||
} from "../../utils/utils";
|
||||
import BaseModal from "../baseModal";
|
||||
import { handleKeyDown } from "../../utils/reactflowUtils";
|
||||
|
||||
export default function GenericModal({
|
||||
field_name = "",
|
||||
|
|
@ -213,6 +214,9 @@ export default function GenericModal({
|
|||
checkVariables(e.target.value);
|
||||
}}
|
||||
placeholder="Type message here."
|
||||
onKeyDown={(e) => {
|
||||
handleKeyDown(e, inputValue, '');
|
||||
}}
|
||||
/>
|
||||
) : type === TypeModal.PROMPT && !isEdit ? (
|
||||
<TextAreaContentView />
|
||||
|
|
@ -225,6 +229,9 @@ export default function GenericModal({
|
|||
setInputValue(e.target.value);
|
||||
}}
|
||||
placeholder="Type message here."
|
||||
onKeyDown={(e) => {
|
||||
handleKeyDown(e, value, '');
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<></>
|
||||
|
|
|
|||
|
|
@ -232,3 +232,14 @@ export function addVersionToDuplicates(flow: FlowType, flows: FlowType[]) {
|
|||
|
||||
return newName;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
export function handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>, inputValue: string | string[] | null, block: string)
|
||||
{
|
||||
if (e.ctrlKey && inputValue === block && e.key === "Backspace") {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
};
|
||||
>>>>>>> bugfix-backctrl
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue