Skip to content
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

Add forced update of ScrollView on iOS #1442

Merged
merged 4 commits into from
Oct 22, 2023

Conversation

cat0363
Copy link
Contributor

@cat0363 cat0363 commented Oct 4, 2023

This PR resolves the issue where the Expander tap does not work when the Expander is placed outside the display range of the ScrollView.

Description of Change

Fixed to call InvalidateMeasure method if element.Parent is ScrollView.

[src\CommunityToolkit.Maui\Views\Expander\Expander.shared.cs]

void ResizeExpanderInItemsView(TappedEventArgs tappedEventArgs)
{
    if (Header is null)
    {
        return;
    }

    Element element = this;
    var size = IsExpanded
        ? Measure(double.PositiveInfinity, double.PositiveInfinity, MeasureFlags.IncludeMargins).Request
        : Header.Measure(double.PositiveInfinity, double.PositiveInfinity);

    while (element is not null)
    {
        if (element.Parent is ListView && element is Cell cell)
        {
#if IOS || MACCATALYST
            throw new NotSupportedException($"{nameof(Expander)} is not yet supported in {nameof(ListView)}");
#else
            cell.ForceUpdateSize();
#endif
        }
#if IOS || MACCATALYST || WINDOWS
        else if (element is CollectionView collectionView)
        {
            var tapLocation = tappedEventArgs.GetPosition(collectionView);
            ForceUpdateCellSize(collectionView, size, tapLocation);
        }
#endif
#if IOS || MACCATALYST
        else if (element is ScrollView scrollView)
        {
            (scrollView as IView).InvalidateMeasure();
        }
#endif

        element = element.Parent;
    }
}

Linked Issues

PR Checklist

Additional information

Below are the verification results.

iPhone.14.iOS.16.4.2023-10-04.16-35-35.mp4

You can see that the Expander placed outside the visible range of the ScrollView is working.

@cat0363
Copy link
Contributor Author

cat0363 commented Oct 4, 2023

Additional Information:
If Issue #1439 is a similar issue to Issue #14257, this PR is a temporary workaround until a solution for Issue #14257 is released.

@VladislavAntonyuk VladislavAntonyuk added the hacktoberfest-accepted A PR that has been approved during Hacktoberfest label Oct 6, 2023
@TheCodeTraveler TheCodeTraveler enabled auto-merge (squash) October 22, 2023 11:10
@TheCodeTraveler TheCodeTraveler merged commit 5832f3a into CommunityToolkit:main Oct 22, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
hacktoberfest-accepted A PR that has been approved during Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Expander in scrollview does not expand on IOS
3 participants