Skip to content

Commit 5a68fe8

Browse files
authored
Modal outstanding issues (#15445) (#15450)
* solve modal foreground/background issue and only have a closebutton on title bar with no icon * Change files
1 parent 2b973eb commit 5a68fe8

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "solve modal foreground/background issue and only have a closebutton on title bar with no icon",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

vnext/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::F
6666
m_appWindow = nullptr;
6767
}
6868

69+
// Bring parent window to foreground
70+
if (m_parentHwnd) {
71+
SetForegroundWindow(m_parentHwnd);
72+
SetFocus(m_parentHwnd);
73+
}
74+
6975
// Close bridge
7076
m_popUp.Close();
7177
m_popUp = nullptr;
@@ -247,6 +253,12 @@ struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::F
247253
m_reactContext.Properties().Handle(), m_prevWindowID);
248254
}
249255

256+
// Bring parent window to foreground
257+
if (m_parentHwnd) {
258+
SetForegroundWindow(m_parentHwnd);
259+
SetFocus(m_parentHwnd);
260+
}
261+
250262
// Dispatch onDismiss event
251263
if (auto eventEmitter = EventEmitter()) {
252264
::Microsoft::ReactNativeSpecs::ModalHostViewEventEmitter::OnDismiss eventArgs;
@@ -287,9 +299,16 @@ struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::F
287299
overlappedPresenter.IsModal(true);
288300
overlappedPresenter.SetBorderAndTitleBar(true, true);
289301

302+
// modal should only have close button
303+
overlappedPresenter.IsMinimizable(false);
304+
overlappedPresenter.IsMaximizable(false);
305+
290306
// Apply the presenter to the window
291307
m_appWindow.SetPresenter(overlappedPresenter);
292308

309+
// Hide the title bar icon
310+
m_appWindow.TitleBar().IconShowOptions(winrt::Microsoft::UI::Windowing::IconShowOptions::HideIconAndSystemMenu);
311+
293312
// Set initial title using the stored local props
294313
if (m_localProps && m_localProps->title.has_value()) {
295314
winrt::hstring titleValue = winrt::to_hstring(m_localProps->title.value());

0 commit comments

Comments
 (0)