Skip to content

Button with OutlinedButtonStyle or MaterialOutlinedButtonStyle style stay selected if we execute a task #12028

Closed

Description

@SamuelPelletierEvraire

Current behavior

This problem occurs when a button containing the OutlinedButtonStyle style executes a task requiring a delay before execution, for example Task.Delay(2000).

Expected behavior

The button don't stay selected.

How to reproduce it (as minimally and precisely as possible)

UnoIssue.zip

Workaround

NA

Works on UWP/WinUI

Yes

Environment

Other

NuGet package version(s)

            <PackageReference Include="Chinook.DynamicMvvm" Version="1.1.5" />
	<PackageReference Include="Uno.Dsp.Tasks" Version="1.0.1" />
	<PackageReference Include="Uno.WinUI" Version="4.8.24" />
	<PackageReference Include="Uno.Resizetizer" Version="1.0.2" />
	<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
	<PackageReference Include="Uno.Extensions.Configuration" Version="2.3.6" />
	<PackageReference Include="Uno.Extensions.Http" Version="2.3.6" />
	<PackageReference Include="Uno.Extensions.Http.Refit" Version="2.3.6" />
	<PackageReference Include="Uno.Extensions.Logging.WinUI" Version="2.3.6" />
	<PackageReference Include="Uno.Extensions.Serialization.Http" Version="2.3.6" />
	<PackageReference Include="Uno.Extensions.Serialization.Refit" Version="2.3.6" />
	<PackageReference Include="Uno.Material.WinUI" Version="2.5.3" />
	<PackageReference Include="Uno.Toolkit.WinUI.Material" Version="2.5.5" />
	<PackageReference Include="Uno.Toolkit.WinUI" Version="2.5.5" />
	<PackageReference Include="Uno.Extensions.Authentication.WinUI" Version="2.3.6" />
	<PackageReference Include="Uno.Extensions.Hosting.WinUI" Version="2.3.6" />
	<PackageReference Include="Uno.Extensions.Localization.WinUI" Version="2.3.6" />
	<PackageReference Include="Uno.Extensions.Navigation.Toolkit.WinUI" Version="2.3.6" />
	<PackageReference Include="Uno.Extensions.Navigation.WinUI" Version="2.3.6" />
	<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />

Affected platforms

Android, iOS, Windows

IDE

Visual Studio 2022

IDE version

17.5.3

Relevant plugins

No response

Anything else we need to know?

No response

Activity

  1. added
    kind/bug
    triage/untriaged
    difficulty/tbd
    on Apr 21, 2023
  2. kazo0 commented on Apr 24, 2023

    @kazo0
    Contributor

    @LeKillerDuTurffu
    Could you provide a visual of the issue because I can't seem to reproduce this

    Android:

    android-button-command

    Windows:

    win-button-command

  3. kazo0 commented on Apr 24, 2023

    @kazo0
    Contributor

    Oh I see the issues, sorry, the button is staying in the selected state after re-enabling

  4. kazo0 commented on Apr 24, 2023

    @kazo0
    Contributor

    Ok so I see what's happening. It's not actually staying "selected", the reason is that the button that is clicked is in the PointerFocused visual state when the button is re-enabled. As per the Material 3 Design Guidelines, the Focused state should look like it does in the sample app:

    https://m3.material.io/components/buttons/specs#3e0f4ace-3ed5-4d4e-89ae-3743e76c62f4

    image

    On the Windows app, if you were to Tab through the controls on the page, you'd see the same effect once the Material button was tabbed into focus. It looks like we are actually doing this for both the PointerFocused and the Focused visual states.

    If we were to create a custom style in the app like this:

    <Style x:Key="MyButtonStyle"
    		TargetType="Button">
    	<Setter Property="Template">
    		<Setter.Value>
    			<ControlTemplate TargetType="Button">
    				<Grid x:Name="Root"
    						Background="Red">
    					<VisualStateManager.VisualStateGroups>
    						<VisualStateGroup x:Name="FocusStates">
    							<VisualState x:Name="Unfocused" />
    							<VisualState x:Name="Focused">
    								<VisualState.Setters>
    									<Setter Target="Root.Background" Value="Green" />
    								</VisualState.Setters>
    							</VisualState>
    							<VisualState x:Name="PointerFocused">
    								<VisualState.Setters>
    									<Setter Target="Root.Background" Value="Green" />
    								</VisualState.Setters>
    							</VisualState>
    						</VisualStateGroup>
    					</VisualStateManager.VisualStateGroups>
    					<ContentPresenter />
    				</Grid>
    			</ControlTemplate>
    		</Setter.Value>
    	</Setter>
    </Style>

    We'd also see it occur for that non-material style:

    pointerfocused

    @Xiaoy312 @agneszitte - this looks to be because we are still in the PointerFocused visual state, which makes sense but does look a little odd here. Seems to just be the normal Windows behavior, though. Anything we can do here? Besides eventually allowing for Lightweight Styling and setting the eventual PointerFocusedBackgroundBrush to Transparent?

  5. kazo0 commented on May 1, 2023

    @kazo0
    Contributor

    @Xiaoy312 / @agneszitte - anything we can do here? Does removing the PointerFocused VisualState in the template make sense or no?

  6. added
    area/theming
    project/styling 👔
    difficulty/starter 🚀
    and removed
    triage/untriaged
    difficulty/tbd
    on Sep 11, 2023
  7. github-actions commented on Aug 9, 2025

    @github-actions
    Contributor

    Hey there — just a heads-up that this issue has been quiet for over a year. If there’s no update or comment in the next 10 days, it’ll be closed automatically. Feel free to remove the stale label or drop a note to keep it open.

  8. added
    stale
    on Aug 9, 2025
  9. removed
    stale
    on Aug 11, 2025
  10. MartinZikmund commented on Aug 11, 2025

    @MartinZikmund
    Member

    Likely still relevant

  11. added
    triage/potentially-fixed
    on Apr 10, 2026
  12. MartinZikmund commented on Apr 10, 2026

    @MartinZikmund
    Member

    Repro generator

    Runtime test(s) added in branch `dev/mazi/repro/12028`:

    • `src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Button.cs` → `When_Button_Does_Not_Stay_Pressed_During_Async_Click_Handler`

    ⚠️ The test passes on current master (Skia target). The test verifies that the Button exits the Pressed visual state immediately after pointer release, even when the Click handler runs a long async operation. A PR has been created to add the passing test as regression coverage.

    The original issue was reported with Uno.Material's OutlinedButtonStyle on Android and iOS. If the root cause is in the Material package's custom VisualStates or in touch-specific pointer capture behavior, it may still need investigation in uno.themes. Verification on native Android/iOS targets is recommended.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/themingdifficulty/starter 🚀has-repro-branchkind/bugproject/styling 👔triage/potentially-fixed

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions