mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-28 06:22:45 -08:00
fix: re-enable modal input capture on active overlay window
This commit is contained in:
@@ -281,6 +281,41 @@ test('modal runtime notifies callers when modal input state becomes active/inact
|
||||
assert.deepEqual(state, [true, false]);
|
||||
});
|
||||
|
||||
test('notifyOverlayModalOpened enables input on visible main overlay window when no modal window exists', () => {
|
||||
const mainWindow = createMockWindow();
|
||||
mainWindow.visible = true;
|
||||
mainWindow.ignoreMouseEvents = true;
|
||||
const state: boolean[] = [];
|
||||
|
||||
const runtime = createOverlayModalRuntimeService(
|
||||
{
|
||||
getMainWindow: () => mainWindow as never,
|
||||
getModalWindow: () => null,
|
||||
createModalWindow: () => {
|
||||
throw new Error('modal window should not be created when main overlay is visible');
|
||||
},
|
||||
getModalGeometry: () => ({ x: 0, y: 0, width: 400, height: 300 }),
|
||||
setModalWindowBounds: () => {},
|
||||
},
|
||||
{
|
||||
onModalStateChange: (active: boolean): void => {
|
||||
state.push(active);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const sent = runtime.sendToActiveOverlayWindow('runtime-options:open', undefined, {
|
||||
restoreOnModalClose: 'runtime-options',
|
||||
});
|
||||
runtime.notifyOverlayModalOpened('runtime-options');
|
||||
|
||||
assert.equal(sent, true);
|
||||
assert.equal(state, [true]);
|
||||
assert.equal(mainWindow.ignoreMouseEvents, false);
|
||||
assert.equal(mainWindow.isFocused(), true);
|
||||
assert.equal(mainWindow.webContentsFocused, true);
|
||||
});
|
||||
|
||||
test('handleOverlayModalClosed resets modal state even when modal window does not exist', () => {
|
||||
const state: boolean[] = [];
|
||||
const runtime = createOverlayModalRuntimeService(
|
||||
|
||||
@@ -65,6 +65,20 @@ export function createOverlayModalRuntimeService(
|
||||
return null;
|
||||
};
|
||||
|
||||
const getActiveOverlayWindowForModalInput = (): BrowserWindow | null => {
|
||||
const modalWindow = deps.getModalWindow();
|
||||
if (modalWindow && !modalWindow.isDestroyed()) {
|
||||
return modalWindow;
|
||||
}
|
||||
|
||||
const visibleMainWindow = deps.getMainWindow();
|
||||
if (visibleMainWindow && !visibleMainWindow.isDestroyed()) {
|
||||
return visibleMainWindow;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const isWindowReadyForIpc = (window: BrowserWindow): boolean => {
|
||||
if (window.webContents.isLoading()) {
|
||||
return false;
|
||||
@@ -245,7 +259,7 @@ export function createOverlayModalRuntimeService(
|
||||
const notifyOverlayModalOpened = (modal: OverlayHostedModal): void => {
|
||||
if (!restoreVisibleOverlayOnModalClose.has(modal)) return;
|
||||
notifyModalStateChange(true);
|
||||
const targetWindow = deps.getModalWindow();
|
||||
const targetWindow = getActiveOverlayWindowForModalInput();
|
||||
clearPendingModalWindowReveal();
|
||||
if (!targetWindow || targetWindow.isDestroyed()) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user