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

[Android] CollectionView + HeightRequest + Editor dynamic sizing is broken #22651

Open
BruceHaley opened this issue May 25, 2024 · 3 comments
Open
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView delighter-sc platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@BruceHaley
Copy link

BruceHaley commented May 25, 2024

Description

When a CollectionView has a HeightRequest property setting and its DataTemplate contains an Editor control, and when there are enough different-sized listed items to more than fill the page, displayed item sizes are randomly wrong.

I have created a repro in code using Microsoft's dotnet maui-samples.

Repro # 1:

  1. Clone my modified maui-samples repo here: https://github.com/BruceHaley/maui-samples/tree/main
  2. Build the CollectionViewDemos project.
  3. Run it on an Android device.
  4. Pick the menu item, "Scroll mode when adding items". Wait for the list to finish populating.
  5. Now scroll the list up and down a few times.

Expected:

Listed items would all remain properly sized according to the amount of text in each.

Actual:

Some items are redisplayed the wrong size, leaving gaps at the bottom of the text. Each time you scroll, they come out sized differently, apparently randomly.

Repro # 2:

You can code your own repro from the dotnet maui-samples by pasting the following code snippet into the file ItemsUpdatingScrollModePage.xaml:

        <CollectionView x:Name="collectionView"
                        HeightRequest="500"
                        ItemsSource="{Binding Monkeys}">
            <CollectionView.ItemTemplate>
                <DataTemplate>
                        <Editor
                            Text="{Binding Details}"
                            Margin="5"
                            TextColor="LightGray"
                            BackgroundColor="DarkRed"
                            FontAttributes="Bold" />
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>

After pasting, follow the directions for Repro # 1.

Notes:

  • This bug may exist on other devices. I only tested this on Android.
  • The key to the problem appears to be specifying both HeightRequest and Editor at the same time. See the code snippet. If you either delete the HeightRequest line, or you change Editor to Label, the problem goes away.

Link to public reproduction project repository

https://github.com/BruceHaley/maui-samples/tree/main

Version with bug

8.0.21 SR4.1

Is this a regression from previous behavior?

Unknown. Did not test other versions

Last version that worked well

Unknown

Affected platforms

Android, maybe others.

Affected platform versions

Android 12

Did you find any workaround?

No.

@BruceHaley BruceHaley added the t/bug Something isn't working label May 25, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@BruceHaley BruceHaley changed the title [Android] CollectionView HeightRequest Editor dynamic sizing is broken [Android] CollectionView + HeightRequest + Editor dynamic sizing is broken May 26, 2024
@ninachen03
Copy link
Collaborator

Verified this issue with Visual Studio 17.11.0 Preview 1.0 (8.0.40 & 8.0.21& & 8.0.3). Can repro it.

@ninachen03 ninachen03 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels May 27, 2024
@BruceHaley
Copy link
Author

BruceHaley commented May 28, 2024

I found a workaround for this problem: Add the property AutoSize="TextChanges" to the Editor control, as in:

      <Editor 
          Text="{Binding Details}"
          TextColor="LightGray"
          FontAttributes="Bold"
          AutoSize="TextChanges"
          VerticalOptions="CenterAndExpand" />

With that change, there are no more sizing errors. Would be good if this were documented somewhere, like maybe here. Thanks.

@Eilon Eilon added the area-controls-collectionview CollectionView, CarouselView, IndicatorView label May 28, 2024
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Jun 4, 2024
@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 3, 2024
@samhouts samhouts added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView delighter-sc platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants