-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
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 via closePortal() when using const { 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 config
<FlatfileProvider config={{
closeSpace: {
// operation: not provided on purpose
onClose() {
// this will trigger when the user clicks the "X" close button,
// but not when the portal is closed programatically
}
}
>
{children}
</FlatfileProvider>but 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})?
useFlatfile({
onClose() {
// detects when the portal is closed for any reason,
// but doesn't provide a reason.
}
)This is insufficient, because I want to detect if it was closed by clicking the "X" (more like a "onCancel" event)
My workarounds
- Wrapped
useFlatfilewith 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 */ } }) - Emitted a custom event on
closeSpace: { onClose () { } }, that can be detected elsewhere in the application
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels