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

Umbraco radio buttons not checked by default (on load) #9683

Closed
zspasojevic opened this issue Jan 19, 2021 · 7 comments · Fixed by #9685
Closed

Umbraco radio buttons not checked by default (on load) #9683

zspasojevic opened this issue Jan 19, 2021 · 7 comments · Fixed by #9685

Comments

@zspasojevic
Copy link

zspasojevic commented Jan 19, 2021

We're implementing some custom cms section and trying to use umbraco radio buttons there.
The default button selection is not working on page load despite the fact that is has model="true" set properly.

Umbraco version

Seems like all 8+ versions including the current

Reproduction

Steps to reproduce

Create some custom section in CMS that has a radio button with multiple options in it and set one of them to be selected by default on page load.

Expected result

To have an option selected by default on page load

Actual result

None of the radio button options is selected on page load.

We had a look at some of the source files since with umbraco checkboxes this functionality works. We noticed the differences with the localisationService not being passed in inside onLoad() function for radio buttons. Could this be what's causing it to fail?

Radio Button

Checkbox

image

@bjarnef
Copy link
Contributor

bjarnef commented Jan 19, 2021

@zspasojevic strange anyone hasn't noticed this. Yeah, it seems this PR #6797 added localizationService to the controller, but didn't inject the service.

@bjarnef
Copy link
Contributor

bjarnef commented Jan 19, 2021

@zspasojevic do you use the label-key with <umb-radiobutton>?

Also ensure the component has a end-closing tag end not is self-closing (void element).

@zspasojevic
Copy link
Author

Hi @bjarnef. No, we're not using the label-key, we don't have a need for dictionary/localization. This is a code snippet:
image
So even if we hardcode the model to true, it won't be checked by default.

@bjarnef
Copy link
Contributor

bjarnef commented Jan 20, 2021

Okay, the missing localizationService might still affect this. We need to check this with the latest changes, where the missing service is injected.

However I think the issue here is that you set value="0" and value="3", but model is true and false so they will never match.

You can see this example from core, where it is used for relation types:
https://github.com/umbraco/Umbraco-CMS/blob/v8/contrib/src/Umbraco.Web.UI.Client/src/views/relationtypes/views/relationType.html#L11-L28

You should probably either remove the value attributes and handle the logic in the on-change function or use something like vm.selectedValue in the model attributes.

@nul800sebastiaan
Copy link
Member

nul800sebastiaan commented Jan 20, 2021

The localizationService problem is fixed with PR #9685 and I've cherry picked this for all upcoming patch releases of 8.6 upwards. Additionally, this fix will be available in the upcoming v8.11.0 (of which the RC should be out later this week).

@bjarnef
Copy link
Contributor

bjarnef commented Jan 20, 2021

@nul800sebastiaan v8.11.0-RC is already out 😁 .. but great to include this in final release of v8.11.0 👍
https://umbraco.com/blog/umbraco-811-release-candidate/
https://our.umbraco.com/download/releases/8110

@nul800sebastiaan
Copy link
Member

duh.. too eagerly copy-pasted 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants