Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: titleBarOverlay and ready-to-show conflict #42409

Open
3 tasks done
Juruoer opened this issue Jun 7, 2024 · 1 comment
Open
3 tasks done

[Bug]: titleBarOverlay and ready-to-show conflict #42409

Juruoer opened this issue Jun 7, 2024 · 1 comment

Comments

@Juruoer
Copy link

Juruoer commented Jun 7, 2024

Preflight Checklist

Electron Version

28.2.0

What operating system are you using?

Windows

Operating System Version

Windows 11 23H2

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

When creating a BrowserWindow, set show: false in the options and listen for the ready-to-show event of the window. When the event is triggered, the window will be displayed. Generally speaking, this will run normally. But when titleBarStyle:' hidden and titleBarOverlay: true are set in the options, window will not send a ready-to-show event unless show in the options is set to true.

Actual Behavior

My code is as follows:

import { app, BrowserWindow, Menu } from 'electron'
import { join } from 'path'

/** 主窗口 */
let mainWindow: BrowserWindow | null = null

/** 创建主窗口 */
function createWindow() {
  mainWindow = new BrowserWindow({
    width: 900,
    height: 670,
    show: false,
    backgroundColor: 'rgb(32, 32, 32)',
    titleBarStyle: 'hidden',
    titleBarOverlay: {
      color: 'rgba(0, 0, 0, 0)',
      symbolColor: 'rgb(255, 255, 255)',
      height: 32
    },
    webPreferences: {
      preload: join(__dirname, '../preload/index.js')
    }
  })

  mainWindow.on('closed', () => {
    mainWindow = null
  })

  mainWindow.on('ready-to-show', () => {
    console.log('ready')
    mainWindow?.show()
  })

  mainWindow.webContents.loadURL('https://electronjs.org')
}

/**
 * 初始化
 */
function initialize(): void {
  app.whenReady().then(() => {
    createWindow()
  })
}

// 取消默认菜单栏
Menu.setApplicationMenu(null)

// 初始化程序
initialize()

The console will not print ready, and the window will not be displayed, but when I set show to true, the window will be displayed normally, and after it is displayed, it will print ready. This means that the window will be displayed before ready-to-show, but this is not what I need. I want the window to be displayed after ready-to-show.

Testcase Gist URL

No response

Additional Information

No response

@Juruoer Juruoer changed the title [Bug]: [Bug]: titleBarOverlay and ready-to-show conflict Jun 7, 2024
@VerteDinde VerteDinde added the has-repro-comment Issue has repro in comments label Jun 14, 2024
@mlaurencin
Copy link
Contributor

Thank you for taking the time to report this issue and helping to make Electron better.

The version of Electron you reported this on has been superseded by newer releases. See our supported versions documentation.

If you’re still experiencing this issue in Electron 29.x.y or later, please add a comment specifying the version you’re testing with and any other new information that a maintainer trying to reproduce the issue should know.

I’m setting the blocked/need-info label for the above reasons. This issue will be closed 10 days from now if there is no response.

Thanks in advance! Your help is appreciated.

@mlaurencin mlaurencin added the blocked/need-info ❌ Cannot proceed without more information label Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@codebytere @VerteDinde @mlaurencin @Juruoer and others