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-cancel event occurs #13103

Open
dg-m opened this issue Dec 10, 2020 · 0 comments
Open

Comments

@dg-m
Copy link

dg-m commented Dec 10, 2020

Description

If a system event occurs while a button is pressed the button released event isn't fired anymore.
The background-color is still on pressed button state.

Steps to Reproduce

  1. Hold down a button
  2. With the other hand pull down the iOS-Control-Center and release it

Expected Behavior

The button is in released state.

Actual Behavior

The button is still in pressed state.

Basic Information

  • Version with issue: 4.8.0.1687
  • iOS: 13.7

Workaround

using System;
using App.Libraries.UiComponents.iOS.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(Button), typeof(ButtonRendereriOS))]

namespace App.Libraries.UiComponents.iOS.Renderers
{
    public class ButtonRendereriOS : ButtonRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Button> e)
        {
            base.OnElementChanged(e);

            if (Control != null && e.NewElement is Button view)
            {
                Control.TouchCancel += SendReleased;
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (Control != null)
            {
                Control.TouchCancel -= SendReleased;
            }

            base.Dispose(disposing);
        }

        void SendReleased(object sender, EventArgs e)
        {
            ((IButtonController)Element)?.SendReleased();
        }
    }
}
@dg-m dg-m added s/unverified New report that has yet to be verified t/bug 🐛 labels Dec 10, 2020
@samhouts samhouts added this to New in Triage Dec 10, 2020
@jsuarezruiz jsuarezruiz added a/button p/iOS 🍎 e/2 🕑 2 and removed s/unverified New report that has yet to be verified labels Dec 10, 2020
@jsuarezruiz jsuarezruiz moved this from New to Ready For Work in Triage Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Triage
  
Ready For Work
Development

Successfully merging a pull request may close this issue.

2 participants