Open Ap73MKa opened 3 weeks ago
Hi,
Can you explain what you mean with "dialog component is destroyed and recreated. This causes the dialog to reset, losing any changes to the record object". When running you repo code, I see this when using a record
for TestObject
, changing the value and then clicking on the overlay:
So the dispose is called but the dialog remains on screen tand the changed value is still shown. This is on Blazor Server.
We are using a GetHashCode()
in our code. The value of this will change when using a record
and a value of a property in that record is changed. Don't think there is anything we can do about that.
Adding the following code to the TestObject
record:
public override int GetHashCode()
{
return base.GetHashCode();
}
prevents the 'Dispose called' toast from being displayed when clicking on the overlay after changing the value. Please confirm that this resolves your issue as well.
🐛 Bug Report
In Fluent UI Blazor from version 4.9.0, when using a record type object and setting the PreventDismissOnOverlayClick parameter for the FluentDialog component, the dialog is destroyed and recreated when any property of the object is modified, and the overlay is clicked. This issue does not occur in earlier versions or when using a class type object.
💻 Repro or Code Sample
Reproduce
Steps to reproduce the issue:
Clone repo
https://github.com/Ap73MKa/fluent-dialog-issue
🤔 Expected Behavior
The dialog should remain open and continue to function without any issue, preserving the updated record object state when interacting with the overlay.
😯 Current Behavior
When any property of the record object is modified, and the overlay is clicked, the dialog component is destroyed and recreated. This causes the dialog to reset, losing any changes to the record object.
💁 Possible Solution
One potential solution is to revert to a previous version of Fluent UI Blazor (before 4.9.0) where this issue is not present. Alternatively, using a class instead of a record for the object passed to the dialog avoids the bug.
🔦 Context
This bug occurred when I was working on a multi-step form on Blazor hybrid for Android. When the user exits input, he may accidentally click on Overlay (that's why PreventDismissOnOverlayClick was installed) and because of this bug, he was transferred to the first stage of the form.
🌍 Your Environment