mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-28 18:22:42 -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]);
|
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', () => {
|
test('handleOverlayModalClosed resets modal state even when modal window does not exist', () => {
|
||||||
const state: boolean[] = [];
|
const state: boolean[] = [];
|
||||||
const runtime = createOverlayModalRuntimeService(
|
const runtime = createOverlayModalRuntimeService(
|
||||||
|
|||||||
@@ -65,6 +65,20 @@ export function createOverlayModalRuntimeService(
|
|||||||
return null;
|
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 => {
|
const isWindowReadyForIpc = (window: BrowserWindow): boolean => {
|
||||||
if (window.webContents.isLoading()) {
|
if (window.webContents.isLoading()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -245,7 +259,7 @@ export function createOverlayModalRuntimeService(
|
|||||||
const notifyOverlayModalOpened = (modal: OverlayHostedModal): void => {
|
const notifyOverlayModalOpened = (modal: OverlayHostedModal): void => {
|
||||||
if (!restoreVisibleOverlayOnModalClose.has(modal)) return;
|
if (!restoreVisibleOverlayOnModalClose.has(modal)) return;
|
||||||
notifyModalStateChange(true);
|
notifyModalStateChange(true);
|
||||||
const targetWindow = deps.getModalWindow();
|
const targetWindow = getActiveOverlayWindowForModalInput();
|
||||||
clearPendingModalWindowReveal();
|
clearPendingModalWindowReveal();
|
||||||
if (!targetWindow || targetWindow.isDestroyed()) {
|
if (!targetWindow || targetWindow.isDestroyed()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user