Fix: API modal not opening with shortcut

This commit is contained in:
igorrCarvalho 2024-06-09 15:36:57 -03:00
commit 81a29da787
2 changed files with 10 additions and 1 deletions

View file

@ -15,6 +15,8 @@ import { Separator } from "../ui/separator";
export default function FlowToolbar(): JSX.Element { export default function FlowToolbar(): JSX.Element {
function handleAPIWShortcut(e: KeyboardEvent) { function handleAPIWShortcut(e: KeyboardEvent) {
e.preventDefault(); e.preventDefault();
console.log("oi");
console.log(openCodeModal);
setOpenCodeModal((oldOpen) => !oldOpen); setOpenCodeModal((oldOpen) => !oldOpen);
} }

View file

@ -31,9 +31,13 @@ const ApiModal = forwardRef(
{ {
flow, flow,
children, children,
open: myOpen,
setOpen: mySetOpen,
}: { }: {
flow: FlowType; flow: FlowType;
children: ReactNode; children: ReactNode;
open: boolean;
setOpen: (a: boolean | ((o?: boolean) => boolean)) => void;
}, },
ref, ref,
) => { ) => {
@ -44,7 +48,10 @@ const ApiModal = forwardRef(
const [activeTweaks, setActiveTweaks] = useState(false); const [activeTweaks, setActiveTweaks] = useState(false);
const { autoLogin } = useContext(AuthContext); const { autoLogin } = useContext(AuthContext);
const [open, setOpen] = useState(false); const [open, setOpen] =
mySetOpen !== undefined && myOpen !== undefined
? [myOpen, mySetOpen]
: useState(false);
const [activeTab, setActiveTab] = useState("0"); const [activeTab, setActiveTab] = useState("0");
const pythonApiCode = getPythonApiCode( const pythonApiCode = getPythonApiCode(
flow?.id, flow?.id,