SamProf / MatBlazor

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

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

Open fedegen opened 4 years ago

fedegen commented 4 years ago

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.

joewilson commented 4 years ago

Same

lindespang commented 4 years ago

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

allnet commented 4 years ago

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?

lindespang commented 4 years ago

@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 commented 4 years ago

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

allnet commented 4 years ago

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 notifications@github.com 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.

lindespang commented 4 years ago

(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 commented 4 years ago

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

lindespang commented 4 years ago

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.

allnet commented 4 years ago

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 notifications@github.com 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.

doyce commented 4 years ago

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.

lindespang commented 4 years ago

@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 :)

allnet commented 4 years ago

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 allnetxr@icloud.com 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 <notifications@github.com mailto:notifications@github.com> 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.

lindespang commented 4 years ago

@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 😉

doyce commented 4 years ago

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

doyce commented 4 years ago

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.

allnet commented 4 years ago

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.

1)

2)

Would love to have both snippets.

Thanks

doyce commented 3 years ago

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.

Christoffleroux commented 3 years ago

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 commented 2 years ago

Hi any updates on this issue

Ogglas commented 1 year ago

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

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