From b6e579a8a60017f38eb14de100333111c90ffa2b Mon Sep 17 00:00:00 2001 From: Abhijeet Jha Date: Tue, 22 Apr 2025 01:37:02 +0530 Subject: [PATCH] Title for modal testing --- .../WindowsModalHostViewComponentView.cpp | 75 ++++++++++++++++++- .../src-win/Libraries/Modal/Modal.windows.js | 11 +++ 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp index 7fc57f309b0..b099066999e 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp @@ -78,6 +78,23 @@ struct ModalHostView : public winrt::implements &newProps, const winrt::com_ptr<::Microsoft::ReactNativeSpecs::ModalHostViewProps> &oldProps) noexcept override { + // Set title from props if available, otherwise use default + if (newProps && newProps->title.has_value()) { + m_pendingTitle = newProps->title.value(); + OutputDebugString( + (L"UpdateProps: Setting title from props: '" + winrt::to_hstring(m_pendingTitle) + L"'.\n").c_str()); + } else { + m_pendingTitle = "Modal Title Default"; // Fallback title + OutputDebugString(L"UpdateProps: Using default title 'Modal Title'.\n"); + } + + m_showTitleBar = true; + + // Debug log for m_window + if (!oldProps || newProps->visible != oldProps->visible) { + OutputDebugString(L"UpdateProps: visible prop has changed.\n"); + } + if (!oldProps || newProps->visible != oldProps->visible) { if (newProps->visible.value_or(true)) { // We do not immediately show the window, since we want to resize/position @@ -87,6 +104,21 @@ struct ModalHostView : public winrt::implements::UpdateProps(view, newProps, oldProps); } @@ -211,6 +243,21 @@ struct ModalHostView : public winrt::implements(); + presenter.SetBorderAndTitleBar(true, true); + OutputDebugString(L"EnsureModalCreated: Set border and title bar explicitly.\n"); + } catch (...) { + OutputDebugString(L"EnsureModalCreated: Failed to apply title to window.\n"); + } + } + // dispatch onShow event if (auto eventEmitter = EventEmitter()) { ::Microsoft::ReactNativeSpecs::ModalHostViewEventEmitter::OnShow eventArgs; @@ -252,8 +299,10 @@ struct ModalHostView : public winrt::implements(); + presenter.SetBorderAndTitleBar(true, true); + OutputDebugString(L"EnsureModalCreated: Set border and title bar explicitly.\n"); + } catch (...) { + OutputDebugString(L"EnsureModalCreated: Failed to apply title to window.\n"); + } + } + #endif m_bridge.ResizePolicy(winrt::Microsoft::UI::Content::ContentSizePolicy::ResizeContentToParentWindow); @@ -344,6 +410,12 @@ struct ModalHostView : public winrt::implements; function confirmProps(props: Props) { @@ -269,6 +274,11 @@ class Modal extends React.Component { } render(): React.Node { + // Add this near the beginning of the render method + if (__DEV__ && this.props.title) { + console.log('Modal: title prop is being passed:', this.props.title); + } + if (!this._shouldShowModal()) { return null; } @@ -325,6 +335,7 @@ class Modal extends React.Component { navigationBarTranslucent={this.props.navigationBarTranslucent} identifier={this._identifier} style={styles.modal} + title={this.props.title} // $FlowFixMe[method-unbinding] added when improving typing for this parameters onStartShouldSetResponder={this._shouldSetResponder} supportedOrientations={this.props.supportedOrientations}