Skip to content

Support drawer menus opening as overlay instead of pushing content in iOS #8038

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

Merged
merged 4 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make above-content mode the new default
  • Loading branch information
d4vidi committed Jun 3, 2025
commit 0f8450891c4c75c9b49a2747774082dfe6a898ce
27 changes: 21 additions & 6 deletions e2e/SideMenu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ import TestIDs from '../playground/src/testIDs';

const {elementByLabel, elementById, expectImagesToBeEqual} = Utils;

describe.each([ 'aboveContent', 'pushContent' ])('SideMenu', (openMode) => {
describe('SideMenu', () => {
beforeEach(async () => {
await device.launchApp({newInstance : true});
await elementById(TestIDs.SIDE_MENU_BTN).tap();

if (openMode === 'aboveContent') {
await elementById(TestIDs.TOGGLE_SIDE_MENU_OPEN_MODE_BTN).tap();
}
});

describe(`Open mode '${openMode}'`, () => {
describe.each(['aboveContent', 'pushContent'])('Open mode %s', (openMode) => {
beforeEach(async () => {
if (openMode === 'pushContent') {
await elementById(TestIDs.TOGGLE_SIDE_MENU_OPEN_MODE_BTN).tap();
}
});

it('close SideMenu and push to stack with static id', async () => {
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
await elementById(TestIDs.LEFT_SIDE_MENU_PUSH_BTN).tap();
Expand Down Expand Up @@ -89,4 +91,17 @@ describe.each([ 'aboveContent', 'pushContent' ])('SideMenu', (openMode) => {
expectImagesToBeEqual(actual, snapshottedImagePath);
});
});

it.e2e(':ios: should open above-content by default', async () => {
await elementById(TestIDs.TOGGLE_SIDE_MENU_OPEN_MODE_BTN).tap(); // aboveContent --> pushContent
await elementById(TestIDs.TOGGLE_SIDE_MENU_OPEN_MODE_BTN).tap(); // pushContent --> undefined
await expect(elementByLabel('Open mode: undefined')).toBeVisible();

await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();

const snapshottedImagePath = `./e2e/assets/side_menu.undefined.png`;
const actual =
await elementById('SideMenuContainer').takeScreenshot(`side_menu_undefined`);
expectImagesToBeEqual(actual, snapshottedImagePath);
});
});
Binary file modified e2e/assets/side_menu.aboveContent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified e2e/assets/side_menu.pushContent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added e2e/assets/side_menu.undefined.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions lib/ios/RNNSideMenuPresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ - (void)applyOptions:(RNNNavigationOptions *)options {
[self.sideMenuController.view
setBackgroundColor:[withDefault.layout.backgroundColor withDefault:nil]];

MMDrawerOpenMode openModeLeft = MMDrawerOpenModePushContent; // Default value
MMDrawerOpenMode openModeLeft = MMDrawerOpenModeAboveContent; // Default value
if (withDefault.sideMenu.left.openMode.hasValue) {
NSString *openModeString = withDefault.sideMenu.left.openMode.get;
openModeLeft = MMDrawerOpenModeFromString(openModeString);
}
[self.sideMenuController side:MMDrawerSideLeft openMode:openModeLeft];

MMDrawerOpenMode openModeRight = MMDrawerOpenModePushContent; // Default value
MMDrawerOpenMode openModeRight = MMDrawerOpenModeAboveContent; // Default value
if (withDefault.sideMenu.right.openMode.hasValue) {
NSString *openModeString = withDefault.sideMenu.right.openMode.get;
openModeRight = MMDrawerOpenModeFromString(openModeString);
Expand Down
3 changes: 0 additions & 3 deletions lib/ios/RNNSideMenuSideOptions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ - (void)mergeOptions:(RNNSideMenuSideOptions *)options {
self.openMode = options.openMode;
}

/**
Converts a string open mode to the equivalent MMDrawerOpenMode enum value
*/
MMDrawerOpenMode MMDrawerOpenModeFromString(NSString *openModeString) {
if ([openModeString isEqualToString:@"aboveContent"]) {
return MMDrawerOpenModeAboveContent;
Expand Down
Loading