Remove solution of christian to implement more general way

This commit is contained in:
Lucas Oliveira 2023-09-27 21:43:15 -03:00
commit 721d04a729

View file

@ -26,55 +26,46 @@ export default function DictAreaModal({
if (value) ref.current = value; if (value) ref.current = value;
}, [ref]); }, [ref]);
//This code prevents delete Node and close modal when user press backspace key
const handleKeyDown = (event) => {
if (event.code === "Backspace") {
event.stopPropagation();
}
};
return ( return (
<div onKeyDown={handleKeyDown} className="h-full w-full"> <BaseModal size="medium-h-full" open={open} setOpen={setOpen}>
<BaseModal size="medium-h-full" open={open} setOpen={setOpen}> <BaseModal.Trigger>{children}</BaseModal.Trigger>
<BaseModal.Trigger>{children}</BaseModal.Trigger> <BaseModal.Header description={CODE_DICT_DIALOG_SUBTITLE}>
<BaseModal.Header description={CODE_DICT_DIALOG_SUBTITLE}> <span className="pr-2">Edit Dictionary</span>
<span className="pr-2">Edit Dictionary</span> <IconComponent
<IconComponent name="BookMarked"
name="BookMarked" className="h-6 w-6 pl-1 text-primary "
className="h-6 w-6 pl-1 text-primary " aria-hidden="true"
aria-hidden="true" />
</BaseModal.Header>
<BaseModal.Content>
<div className="flex h-full w-full flex-col transition-all ">
<JsonView
theme="vscode"
dark={true}
editable
enableClipboard
onEdit={(edit) => {
ref.current = edit["src"];
}}
onChange={(edit) => {
ref.current = edit["src"];
}}
src={ref.current}
/> />
</BaseModal.Header> <div className="flex h-fit w-full justify-end">
<BaseModal.Content> <Button
<div className="nopan nodelete nodrag noundo nocopy flex h-full w-full flex-col transition-all "> className="mt-3"
<JsonView type="submit"
theme="vscode" onClick={() => {
dark={true} onChange(ref.current);
editable setOpen(false);
enableClipboard
onEdit={(edit) => {
ref.current = edit["src"];
}} }}
onChange={(edit) => { >
ref.current = edit["src"]; Save
}} </Button>
src={ref.current}
/>
<div className="flex h-fit w-full justify-end">
<Button
className="mt-3"
type="submit"
onClick={() => {
onChange(ref.current);
setOpen(false);
}}
>
Save
</Button>
</div>
</div> </div>
</BaseModal.Content> </div>
</BaseModal> </BaseModal.Content>
</div> </BaseModal>
); );
} }