[SalesForce] Lightning Web Components – Radio button “checked” not retaining when navigating back and forth

I am not UI/UX person and I need help with setting radio button as checked when used in a LWC inner template-for-loop which involves page navigation and conditional rendering. I am able to get the selected value in my JS controller, but when I navigate back to the previous page, the "checked" property is not retaining although I still have the selected value. It might be easy to understand if you can look at the sample here:-
Sample

The reason I went with custom component for radio group is due to applying CSS to individual radio input.

Any help is appreciated. Thank you!

Best Answer

You have to bind the checked attribute of the radio group to your data (e. g. via adding a checked property to your options object) in order to keep track of the selected dom element.

Updated your example here

Related Topic