Fixes some bug with modals and reactive renderings #907
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The combination of a trigger inside some reactive scope and a headless modal would lead to corrupt application state before this fix.
Due to the natur of portalling, portalled portions of components are not automatically coupled to the reactive rendering of fritz2's mountpoint-concept. The portal-root container resides out of its scope.
That is why we forward the scope to each portal-container and could use the latter to register some lifecycle-hooks in order to remove obsolete portals based upon the re-rendering happening inside fritz2's main
RenderContext
.As modals do not have any relation to its trigger(s) and do not reside inside the same mount-point, they were not coupled to the trigger-flow and its cancellation.
This is now fixed!
If the trigger is removed due to some reactive rendering, also the triggered modal will be removed. This holds also for the usage from within some
Router
-based reactive render-context! So if one manipulates the hash-routing segment, the modal will also be closed now.Notice: Even though toasts are rendered in a similar fashion like modals, the former are handled totally agnostic from any reactive coupled trigger! As the triggering is decoupled from the destruction of a toast, the described bug did not affect toasts!