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

cancel block not called if user taps outside action sheet #531

Open
tcobbs-bentley opened this issue Jan 16, 2021 · 22 comments
Open

cancel block not called if user taps outside action sheet #531

tcobbs-bentley opened this issue Jan 16, 2021 · 22 comments
Assignees

Comments

@tcobbs-bentley
Copy link

I am using an ActionSheetDatePicker with a cancel block on an iPhone. If the user hits the Cancel button, this is called. However, if the user taps outside the the action sheet, the action sheet is hidden, but the cancel block is not executed, so my code doesn't have any (reasonable) way of knowing that the user canceled.

@noorulain17
Copy link
Collaborator

After #528 is merged, this issue will be fixed

@tcobbs-bentley
Copy link
Author

I hadn't seen .tapDismissAction in the API, so wasn't using it. I have updated my code to set it to .cancel, but (as I assume you know) I still didn't get notified when the user tapped above the action sheet. Not reported here, the same thing happens in popover mode on an iPad. Let me know if you want me to create a separate issue for the iPad popover problem.

@Jeepston
Copy link

I confirm: tapDismissAction is not called, if it is not .none. I've tracked it to the fact that when adding gesture recognisers in AbstractActionSheetPicker showActionSheetPicker. _actionSheet.window is always nil, since SWActionSheet window is never called

@noorulain17
Copy link
Collaborator

@Jeepston I agree, my branch #528 is not yet merged so you're facing the issue.
Can you please specify my branch in your Podfile for ActionSheetPicker and test once?

@Jeepston
Copy link

@noorulain17 I would be happy to, if you provide me with the instructions how to specify a brunch in Podfile (never done it before)

@noorulain17
Copy link
Collaborator

Hey @Jeepston
you can use the following code to test on your app

pod 'ActionSheetPicker-3.0', :git => 'https://github.com/skywinder/ActionSheetPicker-3.0.git', :branch => 'broken_tapDismissAction_fix'

You can learn more about changing branch/tag, etc. in Podfile from here

@Jeepston
Copy link

Jeepston commented Feb 2, 2021

@noorulain17 I've tested your branch - the fix works on iPhones, but unfortunately, not on iPads...

@noorulain17
Copy link
Collaborator

noorulain17 commented Feb 2, 2021

Thanks @Jeepston for your feedback. I'll fix that on iPad too. Give me few days.

@migrant
Copy link

migrant commented Apr 20, 2021

I have the same problem and noticed #528. But it have not been merged when 2 month passed

@jakmir
Copy link

jakmir commented Apr 22, 2021

The PR is pending, #528 would easily solve it.

@hechukwu
Copy link

I'm having this issue too has it been fixed

@noorulain17 noorulain17 self-assigned this Sep 28, 2021
@noorulain17
Copy link
Collaborator

@hechukwu the fix has been merged to develop branch, you can test is using

pod 'ActionSheetPicker-3.0', :git => 'https://github.com/skywinder/ActionSheetPicker-3.0.git', :branch => 'develop'

@skywinder or I will release a new version of the library in a few days

@hechukwu
Copy link

Thank you

@hechukwu
Copy link

hechukwu commented Sep 28, 2021

Didn't seem to work. When I tap outside the action sheet and it dismisses when I try to open it again it doesn't work

@hechukwu
Copy link

hechukwu commented Sep 28, 2021

if !pickerIsActive {
pickerIsActive = true
let subspaceName = self.subspaces.map { $0.name }
let title = subspaces.count == 0 ? "There are no subspaces" : "Select Subspace"
let initialIndex = 0
let picker = ActionSheetStringPicker.show(withTitle: title, rows: subspaceName as [Any], initialSelection: initialIndex, doneBlock: { picker, index, value in
self.pickerIsActive = false

           if let subspaceName = value as? String {
                self.subspaceTextField.text = subspaceName
                self.selectedSubspace = self.subspaces[index]
            }
            return
        }, cancel: { actionMultipleStringCancelBlock in
            self.pickerIsActive = false
            return
        }, origin: self.spaceTextField)
        if #available(iOS 13.0, *) {
            picker?.toolbarButtonsColor = .label
            picker?.pickerBackgroundColor = .systemGray6
            picker?.toolbarBackgroundColor = .systemGray6
            picker?.titleTextAttributes = [NSAttributedString.Key.foregroundColor : UIColor.label]
        }
    }

@hechukwu
Copy link

@noorulain17 I'm using the branch but it's still not working

@noorulain17 noorulain17 reopened this Sep 28, 2021
@noorulain17
Copy link
Collaborator

@hechukwu thanks for the update. I'll work on this on the weekend.
Or if you would like to open the fix PR, you're more than welcome :)
Thanks for using ActionSheetPicker.

@hechukwu
Copy link

@noorulain17 sure thing bro. This is a great tool been using for most of my projects.

@tflin
Copy link

tflin commented Jul 11, 2022

@noorulain17 Thanks for the reply. It seems this issue is not fixed on iPhone or iPad. Please help to fix/merge the code if possible. Thanks!

@loilee
Copy link

loilee commented Sep 28, 2022

Any update on this? thanks.

@nihilenz
Copy link

Any news?

@skywinder
Copy link
Owner

skywinder commented Jan 29, 2024

Hi @nihilenz,
I am no longer supporting this library, as I am now 100% focused on blockchain R&D and audits at my company, where I dedicate all my time www.oxor.io.

@tflin, please show your PR.
I appreciate your willingness to help with the project. I can add you to the list of contributors, so you can keep it alive if you're willing to continue its development.

P.S.
Here is an update about adding collaborators. Ping me if you're willing to keep it going.
#348

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

No branches or pull requests

10 participants