Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a6dfa74d authored by Vladislav Kaznacheev's avatar Vladislav Kaznacheev
Browse files

Fix context submenu position

Clear the list of presenters in MenuBuilder when the MenuBuilder
instance is reset via clearAll. This prevents MenuPresenter
instances from accumulating and ensures that a stale instance
MenuPresenter is not activated.

Bug: 72507876
Test: android.view.menu.ContextMenuTest
Change-Id: I4911ca31307bc93901987f08298fa6b2926ba6ab
parent 7f1e49f2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -551,6 +551,7 @@ public class MenuBuilder implements Menu {
        mPreventDispatchingItemsChanged = true;
        clear();
        clearHeader();
        mPresenters.clear();
        mPreventDispatchingItemsChanged = false;
        mItemsChangedWhileDispatchPrevented = false;
        onItemsChanged(true);
+7 −0
Original line number Diff line number Diff line
@@ -41,6 +41,13 @@ public class ContextMenuTest extends ActivityInstrumentationTestCase<ContextMenu
        testMenuPosition(getActivity().getTargetRtl());
    }

    public void testContextMenuPositionRepetitive() throws InterruptedException {
        // Regression test for b/72507876
        testMenuPosition(getActivity().getTargetLtr());
        testMenuPosition(getActivity().getTargetRtl());
        testMenuPosition(getActivity().getTargetLtr());
    }

    private void testMenuPosition(View target) throws InterruptedException {
        final int minScreenDimension = getMinScreenDimension();
        if (minScreenDimension < 320) {