MatBlazor icon indicating copy to clipboard operation
MatBlazor copied to clipboard

MatSelectItem throws an error and the same error appears in the demo in fiddle but does not appear in the main demo page !!!

Open fedegen opened this issue 5 years ago • 21 comments

Hi. I am using MatSelectItem in my project and it throws an error:

Uncaught (in promise) Error: System.FormatException: Input string was not in a correct format.
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x1b0b8f0 + 0x000ce> in <f9608672e47645719a06b8553bcb8b5a>:0

So I checked the examples on the demo page and opening the example in Fiddle threw me the same error: https://blazorfiddle.com/temp/1a3e8675-0e34-4f65-b628-fa4fb567bd74

image

But I detected that the error does not appear on the Demo site !!!! !!!

image

So I exclude some syntax problem or misuse of the component.

Any ideas what may be happening? Maybe some library version problem?

Thanks in advance.

fedegen avatar Apr 10 '20 22:04 fedegen

Same

joewilson avatar May 03 '20 00:05 joewilson

Thanks for using MatBlazor, I'll take a look at it tomorrow.

lindespang avatar May 05 '20 18:05 lindespang

Hello there. Thanks for the awesome product. Any luck with a workaround or fix for dropdown preselection? My client seems to be raising a stink about it but everything else seems clean and awesome. Lmk please . Also are you on Patreon?

allnet avatar May 07 '20 07:05 allnet

@allnet Hi, will take a look at it over the weekend and hopefully fix. Could not find the time yet. The author of this repository @SamProf has a Patreon page https://www.patreon.com/SamProf

Btw this one is related to #524 (Probably the same issue)

lindespang avatar May 07 '20 20:05 lindespang

I've identified the issue and will submit a PR in the near future.

lindespang avatar May 07 '20 21:05 lindespang

Awesome. Thanks so much. Really need this last piece to know this project out of the park. Lol

On May 7, 2020, at 2:32 PM, Victor Lindespång [email protected] wrote:

I've identified the issue and will submit a PR in the near future.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SamProf/MatBlazor/issues/494#issuecomment-625508458, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3MO4LBQSXNV3PV66MNXU3RQMSG5ANCNFSM4MFX4OCQ.

allnet avatar May 08 '20 04:05 allnet

(Copying from previous closed issue)

Seems as there was a problem with the MDC select Component that was recently fixed https://github.com/material-components/material-components-web/pull/5870

Unfortunately it just missed the 6.0.0 release.

I think this will solve the issue and don't think I want to do apply my hack in MatBlazor until I can see how this fix turns out.

lindespang avatar May 08 '20 23:05 lindespang

... Hmm but I think I found something that looks weird anyway in MatSelect, reporting back shortly..

lindespang avatar May 09 '20 10:05 lindespang

Will wait until new MDC Select, sorry.

The workaround is to have your collection initialized before supplying it to the MatSelect since this problem appears if you change the collection after the component has been rendered. So if you have async calls to another API then wait until you have your results before you render your MatSelect.

Why it works in some places and/or sometimes is since there may be (depending on implementation) a race condition between the async service call and the rendering of the MatSelect.

The reason for the FormatException is since we are parsing a JS string representing the index on change returned from the MDCSelect which in this case is an empty string => crash.

lindespang avatar May 09 '20 13:05 lindespang

Thanks so much. Got it working. Looks great!!

Do you do any work for hire on the side?

On May 9, 2020, at 6:39 AM, Victor Lindespång [email protected] wrote:

Will wait until new MDC Select, sorry.

The workaround is to have your collection initialized before supplying it to the MatSelect since this problem appears if you change the collection after the component has been rendered. So if you have async calls to another API then wait until you have your results before you render your MatSelect.

Why it works in some places and/or sometimes is since there may be (depending on implementation) a race condition between the async service call and the rendering of the MatSelect.

The reason for the FormatException is since we are parsing a JS string representing the index on change returned from the MDCSelect which in this case is an empty string => crash.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SamProf/MatBlazor/issues/494#issuecomment-626177713, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3MO4N2YMAFT3HSWGAUJV3RQVMH5ANCNFSM4MFX4OCQ.

allnet avatar May 10 '20 01:05 allnet

This is unfortunatelly not a workaround for me. As I mentioned in my original issue, I need to change the bound collection in runtime based on user interaction, after the component is first rendered.

doyce avatar May 10 '20 07:05 doyce

@doyce I understand. Depending on the frequency of the user interaction it might be feasible to re-render the component?

@allnet Glad to hear it. Not right now since I have a 7 week old kid that is in the centre of attention at the moment :)

lindespang avatar May 10 '20 20:05 lindespang

Also one last question, how do I set a background color for MatTableRow? I want it to be based on evaluating a simple method to determine the color.

I’m sure there is probably some convention I could apply when I need to override the theme. Let me know even if you just point me to a link. Couldn’t really find anything when I looked but I’m an experienced developer but somewhat new to web development.

Thanks

On May 9, 2020, at 6:31 PM, Darryl Hill [email protected] wrote:

Thanks so much. Got it working. Looks great!!

Do you do any work for hire on the side?

On May 9, 2020, at 6:39 AM, Victor Lindespång <[email protected] mailto:[email protected]> wrote:

Will wait until new MDC Select, sorry.

The workaround is to have your collection initialized before supplying it to the MatSelect since this problem appears if you change the collection after the component has been rendered. So if you have async calls to another API then wait until you have your results before you render your MatSelect.

Why it works in some places and/or sometimes is since there may be (depending on implementation) a race condition between the async service call and the rendering of the MatSelect.

The reason for the FormatException is since we are parsing a JS string representing the index on change returned from the MDCSelect which in this case is an empty string => crash.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/SamProf/MatBlazor/issues/494#issuecomment-626177713, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3MO4N2YMAFT3HSWGAUJV3RQVMH5ANCNFSM4MFX4OCQ.

allnet avatar May 10 '20 21:05 allnet

@allnet It's not supported in the MatBlazor API, but you can alter the <td> elements with Blazor syntax to get what you want.

https://blazorfiddle.com/s/fffkrbjd

In my example it's inline style but you can do conditional css classes aswell.

Please acknowledge when you have read this and I will delete both our comments to keep this issue nice and tidy. In the future please create new issue to help us keep this repo clean 😉

lindespang avatar May 10 '20 22:05 lindespang

@lindespang What exactly do you mean by re-rendering the component?

doyce avatar May 11 '20 18:05 doyce

Is there any progress with the bug? I noticed that MatBlazor version 2.6.0 includes MDC components 6.0.0 but the bug is still there.

doyce avatar May 26 '20 15:05 doyce

Just donated some more cash to your PayPal.

Quick question, how did you get the color selector widget that you use in the demo for MatBlazor ?

Would love to implement something similar in the setup of one of my apps. You also have this implemented in the top bar with a tear drop color selector.
I would take either one or both if possible . Hopefully you can just copy and paste from the razor file or send me both html/razor files and I’ll find it.

Just cant seem to figure out how you did it. Thanks so much.

Would love to have both snippets.

Thanks

allnet avatar Jul 01 '20 00:07 allnet

I wonder if this bug will ever be fixed. It can sure be workarounded but I need to workaround it everywhere I use MatSelect component which is pretty annoying. In one case I even needed to replace the component completely because the workaround doesn't work.

doyce avatar Sep 29 '20 12:09 doyce

Hi any word on the issue, i found a workaround for Blazor Server but struggling to wait on async tasks when using WebAssembly. Currently the issue is holding back a prod release.

Christoffleroux avatar Jan 26 '21 19:01 Christoffleroux

Hi any updates on this issue

Christoffleroux avatar Jan 07 '22 12:01 Christoffleroux

I got this error and switched over to use MatSelect instead. No error when using that component

https://www.matblazor.com/Select#MatSelectGuid

Ogglas avatar Feb 24 '23 13:02 Ogglas