SamProf / MatBlazor

Material Design components for Blazor and Razor Components
http://www.matblazor.com
MIT License
2.84k stars 386 forks source link

MatAutocompleteList: StringValue is not refreshed #398

Open angelcolmenares opened 4 years ago

angelcolmenares commented 4 years ago

Hi, Great work! steps to reproduce: go to https://www.matblazor.com/AutocompleteList scroll till Item Template Sample Click on Select Car box Select (Click on) Volkswagen Polo => StringValue = Volkswagen Polo. OK Edit string value in select car box so yo get Volkswagen again select (Click on ) Volkswagen Polo => StringValue remains Volkswagen. Wrong Expected behavior : StringValue in select car box must be Volkswagen Polo

lindespang commented 4 years ago

This is because Value property setter exits prematurely if you select the same item again (which you technically do in your example) See code below:

public TItem Value
        {
            get { return _value; }
            set
            {
                if (EqualValues(value, _value))
                {
                    return;
                }

                _value = value;
                StringValue = EqualValues(Value, default(TItem)) ? string.Empty : ComputeStringValue(Value);
                ValueChanged.InvokeAsync(_value);
            }
        }

I think it makes sense to always update the string value given a valid selection, even if it's the same. (I don't think we should call ValueChanged but atleast update string). Labeling this as a bug and we'll see.