CommunityToolkit / CommunityToolkit/dotnet

`PropertyChanged` triggered on empty string

Open
#872 3 comments 0 reactions 0 assignees View on GitHub
bug :bug:
Dominant language
C#
Stars
3.8k
Forks
400
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

The following returns false even though both are empty strings

```cs
if (!global::System.Collections.Generic.EqualityComparer.Default.Equals(myString, value))
```

### Regression

_No response_

### Steps to reproduce

```text
1.
2. Leave empty and tab in and out.
3. `OnPropertyChanged` (and the other methods) is called
```

### Expected behavior

PropertyChanged should not be triggered when the new value is an empty string for a current empty string value.

### Screenshots

_No response_

### IDE and version

VS 2022

### IDE version

_No response_

### Nuget packages

- [ ] CommunityToolkit.Common
- [ ] CommunityToolkit.Diagnostics
- [ ] CommunityToolkit.HighPerformance
- [X] CommunityToolkit.Mvvm (aka MVVM Toolkit)

### Nuget package version(s)

8.2.2

### Additional context

_No response_

### Help us help you

No, just wanted to report this

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the empty-string TextBox binding case with CommunityToolkit.Mvvm 8.2.2 in VS 2022, then trace the property-notification path used by the `x:Bind` example. Done means leaving an already-empty TextBox no longer calls `OnPropertyChanged` or related methods; add a regression test if the relevant test area is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.