Skip to content

Conversation

SanjaySF4372
Copy link
Collaborator

Problem

When a user long-presses on a collapsed SfExpander header and slides their finger off the expander before releasing (which cancels the expansion), the arrow icon remains stuck in the pressed color instead of returning to the configured HeaderIconColor.

This issue occurs because:

  1. On press: The icon color correctly changes to PressedIconColor
  2. On cancelled/released touch: Only the ripple effect was reset, but the icon color was never restored

Reproduction Steps

  1. Set HeaderIconColor to a distinct color (e.g., Blue)
  2. Set PressedIconColor to a different color (e.g., Red)
  3. Long press on expander header → Arrow turns red
  4. While holding, slide finger off the header area
  5. Release finger → Arrow stays red instead of returning to blue

Solution

Added icon color restoration logic in the OnTouch method for PointerActions.Released and PointerActions.Cancelled events:

For Released events:

  • If mouse is hovering and has visual state groups: restore to HeaderIconColor
  • If mouse is hovering without visual state groups: restore to HoverIconColor
  • If not hovering: restore to HeaderIconColor

For Cancelled events:

  • Always restore to HeaderIconColor (mouse hover is reset)

The restoration logic follows the same pattern as the existing OnPropertyChanged method to ensure consistency with visual state groups and hover behaviors.

Testing

Added unit tests to verify:

  • Icon color restoration on cancelled touch events
  • Correct color restoration based on hover state
  • Proper handling of visual state groups

Code Changes

  • Modified: maui/src/Expander/ExpanderHeader.cs - Added icon color restoration in OnTouch method
  • Added: Unit tests in SfExpanderUnitTests.cs to verify the fix

This is a minimal, surgical fix that only adds the missing color restoration without affecting any other functionality.

Fixes #216.

@RasikaPalanisamy
Copy link
Collaborator

This is fine.

Copy link
Collaborator

@FarjanaParveen FarjanaParveen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes are fine

@PaulAndersonS
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PaulAndersonS PaulAndersonS merged commit 4f045ae into main Jul 27, 2025
1 check passed
@PaulAndersonS PaulAndersonS added this to the v1.0.6 milestone Jul 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

SfExpander arrow can end up the wrong color
4 participants