mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-03-11 17:48:44 -05:00
fix(desktop): reduce quick entry window height, add resize IPC, fix focus
- Reduce initial window height from 500px to 120px so it only shows the input bar without excess space - Add quick-entry:resize IPC channel so the frontend can expand the window when the help modal opens and collapse it when closed - Wait for did-finish-load before showing/focusing the window so the input gets properly focused on each invocation
This commit is contained in:
@@ -16,6 +16,9 @@ const portInUse = require('./portInUse.js')
|
||||
const frontendPath = 'frontend/'
|
||||
const SAFE_PROTOCOLS = new Set(['http:', 'https:', 'mailto:'])
|
||||
|
||||
const QUICK_ENTRY_WIDTH = 680
|
||||
const QUICK_ENTRY_COLLAPSED_HEIGHT = 120
|
||||
|
||||
function safeOpenExternal(url) {
|
||||
try {
|
||||
const parsed = new URL(url)
|
||||
@@ -94,14 +97,12 @@ function createMainWindow() {
|
||||
function createQuickEntryWindow() {
|
||||
const display = screen.getPrimaryDisplay()
|
||||
const {width: screenWidth, height: screenHeight} = display.workAreaSize
|
||||
const winWidth = 680
|
||||
const winHeight = 500
|
||||
|
||||
quickEntryWindow = new BrowserWindow({
|
||||
width: winWidth,
|
||||
height: winHeight,
|
||||
x: Math.round((screenWidth - winWidth) / 2),
|
||||
y: Math.round(screenHeight / 3 - winHeight / 2),
|
||||
width: QUICK_ENTRY_WIDTH,
|
||||
height: QUICK_ENTRY_COLLAPSED_HEIGHT,
|
||||
x: Math.round((screenWidth - QUICK_ENTRY_WIDTH) / 2),
|
||||
y: Math.round(screenHeight / 3 - QUICK_ENTRY_COLLAPSED_HEIGHT / 2),
|
||||
frame: false,
|
||||
transparent: true,
|
||||
alwaysOnTop: true,
|
||||
@@ -150,10 +151,16 @@ function showQuickEntry() {
|
||||
return
|
||||
}
|
||||
|
||||
// Reset to collapsed height for each new invocation
|
||||
quickEntryWindow.setSize(QUICK_ENTRY_WIDTH, QUICK_ENTRY_COLLAPSED_HEIGHT)
|
||||
|
||||
// Reload to reset Vue state (clear previous input)
|
||||
quickEntryWindow.loadURL(`http://127.0.0.1:${serverPort}/?mode=quick-add`)
|
||||
quickEntryWindow.show()
|
||||
quickEntryWindow.focus()
|
||||
// Wait for page to finish loading before showing, so the input gets focused
|
||||
quickEntryWindow.webContents.once('did-finish-load', () => {
|
||||
quickEntryWindow.show()
|
||||
quickEntryWindow.focus()
|
||||
})
|
||||
}
|
||||
|
||||
function hideQuickEntry() {
|
||||
@@ -221,6 +228,12 @@ ipcMain.on('quick-entry:close', () => {
|
||||
hideQuickEntry()
|
||||
})
|
||||
|
||||
ipcMain.on('quick-entry:resize', (_event, width, height) => {
|
||||
if (quickEntryWindow) {
|
||||
quickEntryWindow.setSize(width, height)
|
||||
}
|
||||
})
|
||||
|
||||
// ─── App lifecycle ───────────────────────────────────────────────────
|
||||
app.whenReady().then(() => {
|
||||
startServer((port) => {
|
||||
|
||||
@@ -3,4 +3,5 @@ const { contextBridge, ipcRenderer } = require('electron')
|
||||
|
||||
contextBridge.exposeInMainWorld('quickEntry', {
|
||||
close: () => ipcRenderer.send('quick-entry:close'),
|
||||
resize: (width, height) => ipcRenderer.send('quick-entry:resize', width, height),
|
||||
})
|
||||
|
||||
1
frontend/src/types/quick-entry.d.ts
vendored
1
frontend/src/types/quick-entry.d.ts
vendored
@@ -1,5 +1,6 @@
|
||||
interface Window {
|
||||
quickEntry?: {
|
||||
close: () => void
|
||||
resize: (width: number, height: number) => void
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user