Rocket.Chat.ReactNative icon indicating copy to clipboard operation
Rocket.Chat.ReactNative copied to clipboard

Fix TwoFactor modal centering on tablets

Open deepak0x opened this issue 1 month ago β€’ 7 comments

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-modal to 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

android_before android_after

iOS

ios_before ios_after

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.

deepak0x avatar Dec 05 '25 08:12 deepak0x

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.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Dec 05 '25 08:12 coderabbitai[bot]

@deepak0x Could you please attach a screenshot of the app running on Android or iOS showing the 2FA modal?

Rohit3523 avatar Dec 14 '25 12:12 Rohit3523

sure....

deepak0x avatar Dec 14 '25 12:12 deepak0x

here it Is..

Screenshot 2025-12-14 at 6 16 38β€―PM Screenshot 2025-12-14 at 6 07 02β€―PM

deepak0x avatar Dec 14 '25 12:12 deepak0x

Can you please attach it in PR description

Rohit3523 avatar Dec 14 '25 12:12 Rohit3523

sure

deepak0x avatar Dec 14 '25 12:12 deepak0x

I added it in pr description...

deepak0x avatar Dec 14 '25 13:12 deepak0x