Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "solve modal foreground/background issue and only have a closebutton on title bar with no icon",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::F
m_appWindow = nullptr;
}

// Bring parent window to foreground
if (m_parentHwnd) {
SetForegroundWindow(m_parentHwnd);
SetFocus(m_parentHwnd);
}

// Close bridge
m_popUp.Close();
m_popUp = nullptr;
Expand Down Expand Up @@ -247,6 +253,12 @@ struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::F
m_reactContext.Properties().Handle(), m_prevWindowID);
}

// Bring parent window to foreground
if (m_parentHwnd) {
SetForegroundWindow(m_parentHwnd);
SetFocus(m_parentHwnd);
}

// Dispatch onDismiss event
if (auto eventEmitter = EventEmitter()) {
::Microsoft::ReactNativeSpecs::ModalHostViewEventEmitter::OnDismiss eventArgs;
Expand Down Expand Up @@ -287,9 +299,16 @@ struct ModalHostView : public winrt::implements<ModalHostView, winrt::Windows::F
overlappedPresenter.IsModal(true);
overlappedPresenter.SetBorderAndTitleBar(true, true);

// modal should only have close button
overlappedPresenter.IsMinimizable(false);
overlappedPresenter.IsMaximizable(false);

// Apply the presenter to the window
m_appWindow.SetPresenter(overlappedPresenter);

// Hide the title bar icon
m_appWindow.TitleBar().IconShowOptions(winrt::Microsoft::UI::Windowing::IconShowOptions::HideIconAndSystemMenu);

// Set initial title using the stored local props
if (m_localProps && m_localProps->title.has_value()) {
winrt::hstring titleValue = winrt::to_hstring(m_localProps->title.value());
Expand Down
Loading