Skip to content

[Windows] Fixed Unstable order of Flyout Items with conditional visibility #29197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

SubhikshaSf4851
Copy link
Contributor

Root Cause:

When the visibility of a Flyout item is changed, the UpdateMenuItemSource method simply adds the item to the end, resulting in the original order of the Flyout items being mismatched.

Description of change:

Instead of adding the item, I have retrieved its original position and inserted it back into the Flyout items accordingly, which results the original order being maintained.

Tested the behavior in the following platforms:

  • Windows
  • Android
  • iOS
  • Mac

Issue Fixed:

Fixes #23834

Before Issue Fix After Issue Fix
Issue23834_BeforeFix.mp4
Issue23834_AfterFix.mp4

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Apr 25, 2025
Copy link
Contributor

Hey there @@SubhikshaSf4851! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Apr 25, 2025
{
FlyoutItems.Add(item);
if (index < FlyoutItems.Count)
Copy link
Contributor

Choose a reason for hiding this comment

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

Store FlyoutItems.Count in a variable to minimize repeated property accesses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the changes per your suggestion.

var item = newItems[index];
var flyoutItemIndex = FlyoutItems.IndexOf(item);

if (flyoutItemIndex == -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not big performance differences, but can simplify this using Contains:

if (!FlyoutItems.Contains(item))
    {
        // Use Insert when within bounds, otherwise Add
        if (index < count)
        {
            FlyoutItems.Insert(index, item);
        }
        else
        {
            FlyoutItems.Add(item);
        }
    }

NOTE: count is a variable with the FlyoutItems.Count value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the changes per your suggestion.

@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

App.WaitForElement("button");
App.Tap("button");
App.ShowFlyout();
VerifyScreenshot();
Copy link
Contributor

Choose a reason for hiding this comment

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

Pending snapshots.

Copy link
Contributor

Choose a reason for hiding this comment

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

Snapshots already available in the latest build:

For example:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have committed the pending snapshots

@SubhikshaSf4851 SubhikshaSf4851 marked this pull request as ready for review April 28, 2025 11:15
@SubhikshaSf4851 SubhikshaSf4851 requested a review from a team as a code owner April 28, 2025 11:15
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-flyout Flyout community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/windows 🪟
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unstable order of FlyoutItems with conditional visibility
2 participants