ActionSheetPicker-3.0 icon indicating copy to clipboard operation
ActionSheetPicker-3.0 copied to clipboard

cancel block not called if user taps outside action sheet

Open tcobbs-bentley opened this issue 4 years ago • 22 comments

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.

tcobbs-bentley avatar Jan 16 '21 00:01 tcobbs-bentley

After #528 is merged, this issue will be fixed

noorulain17 avatar Jan 16 '21 00:01 noorulain17

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.

tcobbs-bentley avatar Jan 19 '21 21:01 tcobbs-bentley

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

Jeepston avatar Jan 28 '21 17:01 Jeepston

@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?

noorulain17 avatar Jan 28 '21 19:01 noorulain17

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

Jeepston avatar Jan 29 '21 08:01 Jeepston

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

noorulain17 avatar Jan 29 '21 17:01 noorulain17

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

Jeepston avatar Feb 02 '21 12:02 Jeepston

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

noorulain17 avatar Feb 02 '21 12:02 noorulain17

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

migrant avatar Apr 20 '21 08:04 migrant

The PR is pending, https://github.com/skywinder/ActionSheetPicker-3.0/pull/528 would easily solve it.

jakmir avatar Apr 22 '21 14:04 jakmir

I'm having this issue too has it been fixed

hechukwu avatar Sep 28 '21 08:09 hechukwu

@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

noorulain17 avatar Sep 28 '21 08:09 noorulain17

Thank you

hechukwu avatar Sep 28 '21 08:09 hechukwu

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 avatar Sep 28 '21 08:09 hechukwu

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 avatar Sep 28 '21 08:09 hechukwu

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

hechukwu avatar Sep 28 '21 10:09 hechukwu

@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.

noorulain17 avatar Sep 28 '21 10:09 noorulain17

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

hechukwu avatar Sep 28 '21 11:09 hechukwu

@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!

tflin avatar Jul 11 '22 09:07 tflin

Any update on this? thanks.

loilee avatar Sep 28 '22 05:09 loilee