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

SwitchRow Not responding to second time from user interaction #2241

Open
amrangry opened this issue Feb 1, 2023 · 1 comment
Open

SwitchRow Not responding to second time from user interaction #2241

amrangry opened this issue Feb 1, 2023 · 1 comment

Comments

@amrangry
Copy link

amrangry commented Feb 1, 2023

Describe the bug
SwitchRow Not responding to second time from user interaction

To Reproduce
Steps to reproduce the behavior:

  1. change switch value by clicking, code in the onChange function will be executed
  2. See error: code in the onChange function will not be executed when you change again switch value by clicking,

Expected behavior
execute the code statement in onChange function each time value change of the switch

Screenshots

            SwitchRow(InteractionFormFieldsIds.followupCompletedShortcut.value) {
                $0.title = "Follow Up Completed"
            }.onChange({ row in
                if let switchValue = row.cell.switchControl?.isOn {
                    if switchValue == true {
                        row.cell.switchControl.setOn(false, animated: true)
                
                            DispatchQueue.main.async {
                                self.tableView.reloadData { /* Complete reloading */ }
                            }
                        }
                    } 
                } 
            })

Versions (please complete the following information):

  • Device: iPad
  • OS: iOS 16.0
  • Eureka Version 5.2.1
  • Xcode version 14.1
@mats-claassen
Copy link
Member

Hi @amrangry you can try one of the examples and see that SwitchRow works correctly and onChange is called each time the user taps the switch. Even with your code it works for me.

However why are you changing the switch value from inside onChange?
Also, you probably want to build on row.value instead of row.cell.switchControl?.isOn

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

No branches or pull requests

3 participants