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

Swipe-to-refresh behaviour breaks if RecyclerView's first item's height is set to 0 #788

Open
1 task done
X1nto opened this issue Apr 30, 2021 · 0 comments
Open
1 task done

Comments

@X1nto
Copy link

X1nto commented Apr 30, 2021

Version

def litho_version = "0.41.1"
implementation "com.facebook.litho:litho-core:$litho_version"
implementation "com.facebook.litho:litho-widget:$litho_version"
implementation "com.facebook.litho:litho-sections-core:$litho_version"
implementation "com.facebook.litho:litho-sections-widget:$litho_version"

implementation 'com.facebook.soloader:soloader:0.10.3'

Issues and Steps to Reproduce

Create a RecyclerCollectionComponent with children, set the first item to EmptyComponent, or set its height to 0F, then try pulling down to refresh. it won't work.

Expected Behavior

Pulling down should work fine and a refresh indicator should appear.

Link to Code

CardGroupSpec.java:

@GroupSectionSpec
class CardGroupSpec {

    @OnCreateChildren
    static Children OnCreateChildren(SectionContext c) {
        Children.Builder builder = Children.create();

        for (int i = 0; i < 8; i++) {
            Component component = CardItem.create(c).build();

            //Uncomment this line to reproduce the bug
//            if (i == 0) {
//                component = EmptyComponent.create(c).build(); //Also works with Text.create(c).heightDip(0f).build();
//            }

            builder.child(
                SingleComponentSection
                    .create(c)
                    .component(component)
            );
        }
        return builder.build();
    }
}

CardItemSpec.java:

@LayoutSpec
class CardItemSpec {

    @OnCreateLayout
    static Component OnCreateLayout(ComponentContext c) {
        return Card
            .create(c)
            .marginDip(YogaEdge.ALL, 16F)
            .cardBackgroundColor(Color.GRAY)
            .cornerRadiusDip(16F)
            .content(
                Column
                    .create(c)
                    .heightDip(160f)
                    .build()
            )
            .build();
    }
}

LithoActivity.java:

public class LithoActivity extends AppCompatActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ComponentContext componentContext = new ComponentContext(this);

        RecyclerCollectionComponent recycler = RecyclerCollectionComponent
            .create(componentContext)
            .marginDip(YogaEdge.ALL, 16F)
            .section(CardGroup.create(new SectionContext(componentContext)).build())
            .build();

        setContentView(LithoView.create(this, recycler));
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant