Open cauli opened 1 week ago
Hey Cauli, would you be able to test with const { open } = useFlatfile();
and see if that makes any difference for you?
Hey @Arsik36.
const { open } = useFlatfile();
only allows me to know if the Portal is open or not, it doesn't solve the issue of being able to detect a cancellation (manual closure of the Portal by clicking on the "X")
It's definitely possible to create a workaround component that uses:
open
, useFlatfile({ onClose })
job:outcome-acknowledged
It just ends up being a lot of code for what would be trivial to do on Flatfile's end (emit an event when closing the space)
version:
Flatfile "Platform"
lib:@flatfile/react
Overview
In my specific use-case, it matters if the user has closed the Portal (via the
X
button), or of it was closed programatically viaclosePortal()
when usingconst { openPortal, closePortal } = useFlatfile()
But currently no event is emitted when the user closes the Portal, or when the Space is unmounted.
What did I try?
The only way of detecting this is through
FlatfileProvider
configbut the ergonomics of this is not ideal, because I need to React to that event from inside the provider, not from outside.
What about
useFlatfile({onClose})
?This is insufficient, because I want to detect if it was closed by clicking the "X" (more like a "onCancel" event)
My workarounds
useFlatfile
with my own hook, that stores the state of the Portal, and emits triggersuseMyCustomFlatfile({ onCancel() { /* this is triggered when it's closed without a job:outcome-acknowledged */ } })
closeSpace: { onClose () { } }
, that can be detected elsewhere in the application