Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes some bug with modals and reactive renderings #907

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

Lysander
Copy link
Collaborator

@Lysander Lysander commented Oct 8, 2024

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!

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!

- fixes #906
@Lysander Lysander added bug Something isn't working headless All about headless components and foundations labels Oct 8, 2024
@Lysander Lysander added this to the 1.0-RC20 milestone Oct 8, 2024
@Lysander Lysander requested a review from haukesomm October 8, 2024 13:58
@Lysander Lysander self-assigned this Oct 8, 2024
@Lysander Lysander mentioned this pull request Oct 8, 2024
@Lysander Lysander merged commit 130e039 into master Oct 9, 2024
2 checks passed
@Lysander Lysander deleted the chausknecht/fix-portal-with-modal-bug branch October 9, 2024 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working headless All about headless components and foundations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modal behaviour
2 participants