@@ -1186,6 +1186,11 @@ void WindowsTextInputComponentView::updateProps(
11861186 updateAutoCorrect (newTextInputProps.autoCorrect );
11871187 }
11881188
1189+ if (oldTextInputProps.keyboardType != newTextInputProps.keyboardType ||
1190+ oldTextInputProps.secureTextEntry != newTextInputProps.secureTextEntry ) {
1191+ updateKeyboardType (newTextInputProps.keyboardType );
1192+ }
1193+
11891194 if (oldTextInputProps.selectionColor != newTextInputProps.selectionColor ) {
11901195 m_needsRedraw = true ;
11911196 }
@@ -1432,6 +1437,10 @@ void WindowsTextInputComponentView::onMounted() noexcept {
14321437 m_propBitsMask |= TXTBIT_CHARFORMATCHANGE;
14331438 m_propBits |= TXTBIT_CHARFORMATCHANGE;
14341439 }
1440+
1441+ // Initialize keyboardType
1442+ updateKeyboardType (windowsTextInputProps ().keyboardType );
1443+
14351444 InternalFinalize ();
14361445
14371446 // Handle autoFocus property - focus the component when mounted if autoFocus is true
@@ -1547,25 +1556,59 @@ void WindowsTextInputComponentView::UpdateParaFormat() noexcept {
15471556 m_pf.dwMask = PFM_ALL;
15481557
15491558 auto &textAlign = windowsTextInputProps ().textAlign ;
1559+ auto &baseWritingDirection = windowsTextInputProps ().textAttributes .baseWritingDirection ;
1560+
1561+ // Handle writingDirection (baseWritingDirection)
1562+ // For WritingDirection::Natural, use the computed layout direction from the layout tree
1563+ // since direction can be overridden at any point in the tree
1564+ bool isRTL = false ;
1565+ if (baseWritingDirection.has_value ()) {
1566+ if (*baseWritingDirection == facebook::react::WritingDirection::RightToLeft) {
1567+ isRTL = true ;
1568+ m_pf.dwMask |= PFM_RTLPARA;
1569+ m_pf.wEffects |= PFE_RTLPARA;
1570+ } else if (*baseWritingDirection == facebook::react::WritingDirection::LeftToRight) {
1571+ isRTL = false ;
1572+ // Ensure RTL flag is not set
1573+ m_pf.wEffects &= ~PFE_RTLPARA;
1574+ } else if (*baseWritingDirection == facebook::react::WritingDirection::Natural) {
1575+ // Natural uses the layout direction computed from the tree
1576+ isRTL = (layoutMetrics ().layoutDirection == facebook::react::LayoutDirection::RightToLeft);
1577+ if (isRTL) {
1578+ m_pf.dwMask |= PFM_RTLPARA;
1579+ m_pf.wEffects |= PFE_RTLPARA;
1580+ } else {
1581+ m_pf.wEffects &= ~PFE_RTLPARA;
1582+ }
1583+ }
1584+ } else {
1585+ // No explicit writing direction set - use layout direction from tree
1586+ isRTL = (layoutMetrics ().layoutDirection == facebook::react::LayoutDirection::RightToLeft);
1587+ if (isRTL) {
1588+ m_pf.dwMask |= PFM_RTLPARA;
1589+ m_pf.wEffects |= PFE_RTLPARA;
1590+ } else {
1591+ m_pf.wEffects &= ~PFE_RTLPARA;
1592+ }
1593+ }
15501594
1595+ // Handle textAlign
15511596 if (textAlign == facebook::react::TextAlignment::Center) {
15521597 m_pf.wAlignment = PFA_CENTER;
15531598 } else if (textAlign == facebook::react::TextAlignment::Right) {
15541599 m_pf.wAlignment = PFA_RIGHT;
1600+ } else if (textAlign == facebook::react::TextAlignment::Justified) {
1601+ m_pf.wAlignment = PFA_JUSTIFY;
1602+ } else if (textAlign == facebook::react::TextAlignment::Natural) {
1603+ // Natural alignment respects writing direction
1604+ m_pf.wAlignment = isRTL ? PFA_RIGHT : PFA_LEFT;
15551605 } else {
1606+ // Default to left alignment
15561607 m_pf.wAlignment = PFA_LEFT;
15571608 }
15581609
15591610 m_pf.cTabCount = 1 ;
15601611 m_pf.rgxTabs [0 ] = lDefaultTab;
1561-
1562- /*
1563- if (m_spcontroller->IsCurrentReadingOrderRTL())
1564- {
1565- m_pf.dwMask |= PFM_RTLPARA;
1566- m_pf.wEffects |= PFE_RTLPARA;
1567- }
1568- */
15691612}
15701613
15711614void WindowsTextInputComponentView::OnRenderingDeviceLost () noexcept {
@@ -1826,4 +1869,11 @@ void WindowsTextInputComponentView::updateSpellCheck(bool enable) noexcept {
18261869 winrt::check_hresult (
18271870 m_textServices->TxSendMessage (EM_SETLANGOPTIONS, IMF_SPELLCHECKING, enable ? newLangOptions : 0 , &lresult));
18281871}
1872+
1873+ void WindowsTextInputComponentView::updateKeyboardType (const std::string &keyboardType) noexcept {
1874+ // Store the keyboard type for future use
1875+ // Note: Fabric's windowless RichEdit doesn't have direct InputScope support like Paper's XAML controls.
1876+ // The keyboard type is stored but the actual keyboard behavior is handled by the system's IME.
1877+ m_keyboardType = keyboardType;
1878+ }
18291879} // namespace winrt::Microsoft::ReactNative::Composition::implementation
0 commit comments