Flipboard/bottomsheet

Bug: touch event get wrong after folding soft keyborad

Open

#100 opened on Dec 11, 2015

View on GitHub
 (13 comments) (3 reactions) (0 assignees)Java (609 forks)batch import
bughelp wanted

Repository metrics

Stars
 (4,540 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Step 1: open bottom sheet and expanded it to top. There is a recyclerView which contains EditText items in bottom sheet; Step 2: click any EditText then soft keyboard shows; Step 3: fold the soft keyboard. And now bottom sheet keeps peeked state. Step 4: click top item of recyclerView, the bug is bottom sheet auto hides. Even if I touch the item at bottom position, the bottom sheet doesn't work normally.

After reading source code, I think the problem happens here:(BottomSheetLayout.class line 669)

sheetViewOnLayoutChangeListener = new OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View sheetView, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                int newSheetViewHeight = sheetView.getMeasuredHeight();
                if (state != State.HIDDEN && newSheetViewHeight < currentSheetViewHeight) {
                    // The sheet can no longer be in the expanded state if it has shrunk
                    if (state == State.EXPANDED) {
                        setState(State.PEEKED);
                    }
                    setSheetTranslation(newSheetViewHeight);
                }
                currentSheetViewHeight = newSheetViewHeight;
            }
        };

When soft keyboard is fold, the code "setSheetTranslation(newSheetViewHeight);" isn't execute. This makes onTouchEvent works abnormally.

Contributor guide