Skip to content
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

MatSelectItem does not update selected value #860

Closed
vankampenp opened this issue Mar 10, 2021 · 4 comments
Closed

MatSelectItem does not update selected value #860

vankampenp opened this issue Mar 10, 2021 · 4 comments
Labels
invalid This doesn't seem right

Comments

@vankampenp
Copy link

vankampenp commented Mar 10, 2021

Describe the bug
When an item is selected in MatSelectItem, it is shown in the mdc-select__selected-text span. When clicking the selected item or the dropdown icon, the dropdown list with all items is displayed.
I have an input field that allows me to change the name of the selected item. This state is changed in a separate span, and in the dropdownlist, but not the in the mdc-select__selected-text span.

To Reproduce
see fiddle

In the fiddle this works properly.
But using .NET 5.0 (latest version) and MatBlazor v2.8.0 it does not update the changed selected value. See the screenshot.
After changing the name to "vegateblesss" it is reflected everywhere, but not in the selected text span. When I click on the dropdown, the new name is shown there.

Blazorfiddle link
https://blazorfiddle.com/s/1ku2nt01

Expected behavior
The fiddle shows the expected behavior.

Screenshots
image

@vankampenp vankampenp added the bug Something isn't working label Mar 10, 2021
@enkodellc
Copy link
Collaborator

@vankampenp In your example you hard code value3. Here is updated code so it works.

Here is the offending code:

 @{
     value3=value3Items[2];
 }

Replace this in your code body with a different method of setting the initial value

            ItemType _value3;
            ItemType value3{
                get {
                    if (value3Items.Count() > 2 && _value3 == null) return value3Items[2];
                    else return _value3;
                }
                set => _value3 = value;
            }

https://blazorfiddle.com/s/oki9o9dp

@enkodellc enkodellc added invalid This doesn't seem right and removed bug Something isn't working labels Mar 26, 2021
@w26ak
Copy link

w26ak commented Oct 2, 2023

@enkodellc Sorry, but I do not think your solution is working, at least not for me. The text in dropdown popup is being updated but the text in select itself (the one with CSS class "mdc-select__selected-text") - not.

@enkodellc
Copy link
Collaborator

@w26ak we ported to MudBlazor not long after I posted this. If I posted it it worked for me but that was a LONG time ago now. A lot has have changed with Blazor

@w26ak
Copy link

w26ak commented Oct 4, 2023

Thanks @enkodellc. I ended up with a temporary solution which I suggested in #939. Hope you guys will fix it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants