Thanks to visit codestin.com
Credit goes to github.com

Skip to content

onchange only fired when a breakpoint is set in code-behind #61603

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

Closed
vsfeedback opened this issue Apr 22, 2025 · 2 comments
Closed

onchange only fired when a breakpoint is set in code-behind #61603

vsfeedback opened this issue Apr 22, 2025 · 2 comments
Labels
area-blazor Includes: Blazor, Razor Components Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. Needs: Repro Indicates that the team needs a repro project to continue the investigation on this issue Status: No Recent Activity

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


[severity:I'm unable to use this version]
The following code is a piece of razor that is build up using reflection. In this part the 'property' is a Dictionary and it constructs a dropdown to select an enum (key) and a text-box (value). A + button to add (or update) the kv-pair in the dictionary and below that display a table with kv-pairs. It is a tool to support dev's in faster testing and dev of a specific proprietary system. Lay-out is not important.

if (IsDictionaryProperty(property, out var keyType, out var valueType))
                        {
                            if (keyType is { IsEnum: true } && valueType != null)
                            {
                                var propertyValue = (IDictionary)property. GetValue(WebviewBridge2MessageInstance)!;
                                var selectedKey = keyType.GetEnumValues(). GetValue(0);
                                var selectedValue = valueType.IsValueType ? Activator.CreateInstance(valueType) : null;
                                var inputType = ToInputType(valueType);

<div>
                                    <InputSelect @bind-value="@selectedKey">
                                        @foreach (var enumValue in Enum.GetValues(keyType))
                                        {
                                            <option value="@(enumValue)">@enumValue</option>
                                        }
                                    </InputSelect>
                                    <input type="@inputType" @onchange='(e) => { Dummy(e); selectedValue = e.Value;   }' />
                                    <button @onclick="() => AddDictionaryItem(property, selectedKey!, selectedValue!)" class="addremovebutton add">+</button>
                                </div>

<div>
                                    @foreach (var key in propertyValue.Keys)
                                    {
                                        var value = propertyValue[key];
                                        <div>
                                            <span>@key</span>
                                            <span>@value</span>
                                            <button @onclick="() => RemoveDictionaryItem(property, key)" class="addremovebutton remove">-</button>
                                        </div>
                                    }
                                </div>
                            }
                            else
                            {
                                <span class="unsupported-type">Unsupported type: @property. PropertyType</span>
                            }
                        }

The 'OnUpdate' is never triggered. To confirm this I added a Dummy() method and call it from the OnChange-trigger.

´´´
private void Dummy(object e)
{
Debug.WriteLine($"Current e is : {e}");
}
´´´

When you add some text, hit the button, you expect the onchange to get fired. If I set a breakpoint in the dummy method it stops at the breakpoint, the variable is updated (in the lambda function in razor) and then the AddDictionaryItem is triggered. As one would expect.

If I remove the breakpoint. The OnUpdate does not get triggered, proof Dummy is not called, the onclick (AddDictionaryItem) is called, but fails because the onupdate was not triggered before.

Setting the breakpoint in dummy again does not stop there anymore, unless I reload the page.

Bug ? Or error in my implementation ? Did not found a workaround yet. Any suggestions ?


Original Comments

Feedback Bot on 3/28/2025, 04:36 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Apr 22, 2025
@dotnet-policy-service dotnet-policy-service bot added the Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. label Apr 22, 2025
@javiercn javiercn added the Needs: Repro Indicates that the team needs a repro project to continue the investigation on this issue label Apr 22, 2025
Copy link
Contributor

Thank you for filing this issue. In order for us to investigate this issue, please provide a minimal repro project that illustrates the problem without unnecessary code. Please share with us in a public GitHub repo because we cannot open ZIP attachments, and don't include any confidential content.

@dotnet-policy-service dotnet-policy-service bot added Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. Status: No Recent Activity labels Apr 22, 2025
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components Author: Migration Bot 🤖 The issue was created by a issue mover bot. The author may not be the actual author. Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. Needs: Repro Indicates that the team needs a repro project to continue the investigation on this issue Status: No Recent Activity
Projects
None yet
Development

No branches or pull requests

2 participants