Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] [iOS] Button stays in Pressed state if the touch-up event occurs outside #11430

Closed
hichamboushaba opened this issue Jul 14, 2020 · 1 comment
Assignees
Labels
a/button e/2 🕑 2 in-progress This issue has an associated pull request that may resolve it! p/iOS 🍎 t/bug 🐛

Comments

@hichamboushaba
Copy link

hichamboushaba commented Jul 14, 2020

Description

If you tap a button, then drag your finger outside it, then the button will stay in the "Pressed" state.

Steps to Reproduce

  1. Tap a button
  2. Drag your finger outside the button
  3. Lift up your finger

Expected Behavior

The button will go to the state "Normal"

Actual Behavior

The button will stay in the state "Pressed"

Basic Information

  • Version with issue: 4.7.0.1080

The cause is clear from the ButtonRenderer, we only listen to the TouchUpInside event, so SendReleased is not called when TouchUpOutside occurs.
As a workaround I'm using this Renderer in my project:

    public class ButtonRenderer : Xamarin.Forms.Platform.iOS.ButtonRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
        {
            base.OnElementChanged(e);
            if (e.NewElement != null)
            {
                Control.TouchUpOutside += OnTouchUpOutside;
            }
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (!disposing) return;

            if (Control != null)
            {
                Control.TouchUpOutside -= OnTouchUpOutside;
            }
        }

        private void OnTouchUpOutside(object sender, EventArgs e)
        {
            Element?.SendReleased();
        }
@hichamboushaba hichamboushaba added s/unverified New report that has yet to be verified t/bug 🐛 labels Jul 14, 2020
@jsuarezruiz jsuarezruiz self-assigned this Jul 15, 2020
@jsuarezruiz jsuarezruiz added e/2 🕑 2 and removed s/unverified New report that has yet to be verified labels Jul 15, 2020
@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Jul 15, 2020
@ChristopherStephan
Copy link

ChristopherStephan commented Dec 10, 2020

According to the release notes this issue is fixed in 4.8.0.1269 (https://docs.microsoft.com/en-us/xamarin/xamarin-forms/release-notes/4.8/4.8.0-pre3#issues-fixed) - which is a wrong information: the issue is still reproducible in this version. By updating Xamarin.Forms to 4.8.0.1687 we could confirm that this bug is fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/button e/2 🕑 2 in-progress This issue has an associated pull request that may resolve it! p/iOS 🍎 t/bug 🐛
Projects
None yet
Development

No branches or pull requests

4 participants