Fix TwoFactor modal centering on tablets
Fix: Two-Factor Modal Alignment on Tablet Layouts
Closes #6839
This update fixes the vertical alignment of the two-factor authentication modal on tablets.
Previously, the modal appeared near the top of the screen because the OS sometimes reported a
smaller container height during split screen or multitasking.
π οΈ Changes
- Passed live device dimensions into
react-native-modalto allow correct centering. - Added a modal wrapper style with centered alignment on wider devices.
- No UI changes on phones.
β Testing
- Ran
yarn lint - Manually tested on:
- iPad Pro 11"
- Pixel Tablet
πΈ Before and After (Tablet)
| Device | Before | After |
|---|---|---|
| iPad Pro | ||
| Pixel Tablet |
π± Additional Screenshots (Phone β No UI Change)
Android
iOS
Summary by CodeRabbit
- Style
- Enhanced Two-Factor authentication modal with improved responsiveness and better center alignment across different device sizes.
βοΈ Tip: You can customize this high-level summary in your review settings.
Walkthrough
Two-factor modal now reads device dimensions via react-native's useWindowDimensions and receives deviceHeight/deviceWidth props; container styles add alignItems: 'center'; Xcode project linker flag entries (OTHER_LDFLAGS) changed from a single string to a multi-value array in several build configurations.
Changes
| Cohort / File(s) | Summary |
|---|---|
Responsive dimensions handling app/containers/TwoFactor/index.tsx |
Import useWindowDimensions, derive deviceHeight and deviceWidth, and pass them as props to the Modal component. |
Container alignment app/containers/TwoFactor/styles.ts |
Add alignItems: 'center' to the container style to center modal content horizontally. |
iOS build settings (linker flags) ios/RocketChatRN.xcodeproj/project.pbxproj |
Replace OTHER_LDFLAGS = "$(inherited) "; string entries with an array form OTHER_LDFLAGS = ("$(inherited)", " ",); in multiple Debug/Release XCBuildConfiguration blocks. |
Estimated code review effort
π― 4 (Complex) | β±οΈ ~45 minutes
- Files/areas needing extra attention:
ios/RocketChatRN.xcodeproj/project.pbxprojβ ensure the multi-value OTHER_LDFLAGS change preserves expected linker behavior and doesn't introduce stray blank flags; verify Xcode/CI parsing.app/containers/TwoFactor/index.tsxβ confirm Modal consumes the passed deviceHeight/deviceWidth and that useWindowDimensions usage is correct (no server-side rendering concerns).app/containers/TwoFactor/styles.tsβ validate layout on phone and tablet form factors to avoid horizontal/vertical regressions.
Poem
π° I measured heights and widths with care,
I nudged the box to sit square in the air.
On tablets and phones the modal's aligned,
A hop, a fix β layout nicely refined. π₯
Pre-merge checks and finishing touches
β Failed checks (1 inconclusive)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Out of Scope Changes check | β Inconclusive | The changes to TwoFactor component, styles, and iOS build configuration are mostly in-scope, though the iOS .pbxproj changes appear unrelated to the modal centering fix and warrant clarification. | Clarify the purpose of the OTHER_LDFLAGS changes in the iOS build configuration file and confirm they are necessary for the modal centering fix. |
β Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title clearly and specifically describes the main change: fixing the centering of the TwoFactor modal on tablets. |
| Linked Issues check | β Passed | The PR addresses all coding requirements from issue #6839: passing live device dimensions to Modal, adding centered alignment styling for wider devices, and fixing vertical centering on tablets. |
| Docstring Coverage | β Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
β¨ Finishing touches
- [ ] π Generate docstrings
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
@deepak0x Could you please attach a screenshot of the app running on Android or iOS showing the 2FA modal?
sure....
here it Is..
Can you please attach it in PR description
sure
I added it in pr description...