Radiobuttons not working properly when closing and re-opening a popup

Hi there!

While using the SfPopup for a project, I've encountered an issue with radiobuttons when using a popup to show the radiobuttons. When opening the popup for the first time, the radiobuttons work as expected. You click the radiobutton, the radiobutton goes from an off state to an on state. You close the popup and then re-open it. When clicking any other radiobutton that isn't off, the radiobutton doesn't go to an on state. You have to click the button in question twice to change the state from off to on. I've added a link to a repo where you can see the behavior;

https://github.com/TwisterTies/sfpopupradiobuttons

Steps to reproduce;

- Open the popup by clicking the button on the screen

- Select one of three radiobuttons in the popup

- Close the popup by clicking outside of the popup

- Open the popup again and click any random radiobutton, the state doesn't change from off to on, only when double tapping

Has anybody else encountered this issue?


3 Replies 1 reply marked as answer

SV Suja Venkatesan Syncfusion Team December 29, 2021 01:09 PM UTC

Hi Bryan, 

The reported issue occurs due to RadioButtonGroups, we have checked the sample with SfRadioGroup instead of Xamarin.Forms.RadioButtonGroups it works fine as expected. You can resolve the reported issue either by using SfRadioGroup or clear the Xamarin.Forms.RadioButtonGroup in SfPopupLayout closed event. 

Solution 1:Resolve reported issueUsing SfRadioGroup as like below code snippet. 

Code snippet: 
<SfPopup:SfPopupLayout xmlns=http://xamarin.com/schemas/2014/forms 
                       xmlns:syncfusion="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"  
                       xmlns:vm="clr-namespace:SfPopupRadioButtons.ViewModels.Base"> 
 
 
 <DataTemplate> 
            <StackLayout> 
                <Grid Padding="20,30" RowSpacing="20"> 
            <Grid.RowDefinitions> 
                <RowDefinition Height="Auto"/> 
                <RowDefinition Height="*"/> 
                <RowDefinition Height="Auto"/> 
                <RowDefinition Height="44"/> 
            </Grid.RowDefinitions> 
 
            <Label Grid.Row="0" LineHeight="1.2" Text="This is a title" x:Name="LabelTitle"/> 
 
            <Label Grid.Row="1" LineHeight="1.3" Text="Body text" x:Name="LabelBody"/> 
                            <syncfusion:SfRadioGroup Grid.Row="2"> 
                                <syncfusion:SfRadioButton Padding="5" Text="Value 1" BackgroundColor="{DynamicResource BlockBackgroundColor}" /> 
                                <syncfusion:SfRadioButton Padding="5"  Text="Value 2"  BackgroundColor="{DynamicResource BlockBackgroundColor}" /> 
                                <syncfusion:SfRadioButton Padding="5" Text="Value 3" BackgroundColor="{DynamicResource BlockBackgroundColor}"  /> 
                            </syncfusion:SfRadioGroup> 
 

Please refer our User Guidelines documentation of SfRadioButton and SfRadioGroup for your reference, 
 
Solution 2: Resolve reported issue by clearing the Xamarin.Forms.RadioButtonGroup in SfPopupLayout closed event 

XAML Code snippet: 
SfPopup:SfPopupLayout xmlns=http://xamarin.com/schemas/2014/forms 
                      Closed="SfPopupLayout_Closed" 
   xmlns:vm="clr-namespace:SfPopupRadioButtons.ViewModels.Base"> 


C# Code snippet: 
//Popup.xaml.cs 
 
StackLayout outerstack; 
private void RadioButton_CheckedChanged(object sender, Xamarin.Forms.CheckedChangedEventArgs e) 
        { 
            outerstack = (sender as RadioButton).Parent as StackLayout; 
        } 
 
        private void SfPopupLayout_Closed(object sender, System.EventArgs e) 
        { 
            outerstack.Children.Clear(); 
        } 

We have also modified your sample and attached it here for your reference.  

Please let us know if you have any concern in it. 

Regards, 
Suja 
 


Marked as answer

BR Bryan January 3, 2022 12:14 PM UTC

Hi Suja,

The second solution you provided works perfectly, thank you for answering the question! :)



SV Suja Venkatesan Syncfusion Team January 4, 2022 04:58 AM UTC

Hi Bryan, 

We are glad to know that the provided solution worked at your end. Please let us know if you need further assistance. As always, we are happy to help you out.   

Regards, 
Suja 


Loader.
Up arrow icon