fix: Cannot reopen dialog after closing with escape key in FluentDialog
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start in FluentDialog.OnToggleAsync and inspect the conditional comparing args.Id with Instance?.Id; the issue provides the proposed comparison with Id. Reproduce with the markup-based FluentDialog sample, close it with Escape, and verify that the OnStateChange event fires and the dialog can be reopened with ShowAsync.
Written by the indexing model from the issue text.
Description
🐛 Bug Report
When a FluentDialog is instantiated from markup instead of DialogService, FluentDialog.OnToggleAsync ignores the toggle event. This happens because id doesn't match Instance?.Id because Instance is only set for dialogs launched through DialogService.
💻 Repro or Code Sample
@page "/dialog-repro"
<FluentButton OnClick="OpenAsync">Open dialog</FluentButton>
<p>OnStateChange events: @(_events.Count == 0 ? "(none)" : string.Join(", ", _events))</p>
<FluentDialog @ref="_dialog" OnStateChange="OnStateChange">
<FluentDialogBody>
<TitleTemplate>Repro</TitleTemplate>
<ChildContent>Press Escape to close this dialog.</ChildContent>
</FluentDialogBody>
</FluentDialog>
@code {
private FluentDialog? _dialog;
private readonly List<string> _events = new();
private Task OpenAsync() => _dialog!.ShowAsync();
private void OnStateChange(DialogEventArgs e) => _events.Add(e.State.ToString());
}
🤔 Expected Behavior
When I open a dialog, then close it using the escape key, I should be able to reopen it.
😯 Current Behavior
Instead, the dialog cannot be reopened.
💁 Possible Solution
Change the conditional
if (string.CompareOrdinal(args.Id, Instance?.Id) != 0)
to
``if (string.CompareOrdinal(args.Id, Id) != 0)`
I will create a PR that does this.
🔦 Context
It has caused a bug in my web application, but I was able to fix it with an ugly workaround.
🌍 Your Environment
- Mac OS on Macbook Pro (m1)
- Firefox, and Chrome (did not check others)
- .NET 10 and Fluent UI Blazor library Version 5.0.1
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 493
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 77
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/fluentui-blazor
-
a11y
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
microsoft/fluentui-blazor#5546 ·
Maintainers usually reply within 1 day
-
[FluentTabs]: Screen reader does not announce the accessible name and role for the Delete Tab buttonOpena11y
Difficulty 2/5 Half a day Newbie friendliness 72/100
microsoft/fluentui-blazor#5540 ·
Maintainers usually reply within 1 day
-
a11y
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/fluentui-blazor#5539 ·
Maintainers usually reply within 1 day
-
a11y
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
microsoft/fluentui-blazor#5538 ·
Maintainers usually reply within 1 day
-
a11y
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
microsoft/fluentui-blazor#5537 ·
Maintainers usually reply within 1 day
All issues in microsoft/fluentui-blazor
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 3 days
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug mac アプリ: コード アプリ: チャット 優先: 中 要トリアージ
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
yksr-melt/Meltype#1346 · 2 comments ·
Maintainers usually reply within 1 day