Skip to content

[bug] Window loses focus when creating another window with focus: false, possible deadlock when re-focusing main window manually #5120

@andrepav1

Description

@andrepav1

Describe the bug

We want to be able to create a second window on the onFocus event in a React input component, while keeping the same input focused.

Seems like the intended way of doing this is setting the focus property to false, but this doesn't seem to do the trick.

We also tried using setFocus() inside the "tauri://created" listener to re-focus the primary window manually but this seems to cause a deadlock, as the cursor in the input is blinking but the first button pressed does not register.

Reproduction

  1. Go to repo https://github.com/Andrepav1/tauri-multi-window
  2. Run yarn && yarn start
  3. Run tauri dev
  4. Focus input component and wait window creation
  5. Press any key

Expected behavior

Create the window, while keeping the focus on the input component.

Platform and versions

Environment
› OS: Windows 10.0.19044 X64
› Webview2: 104.0.1293.70
› MSVC:
- Visual Studio Build Tools 2022
› Node.js: 16.15.0
› npm: 8.5.5
› pnpm: 7.1.0
› yarn: 1.22.15
› rustup: 1.25.1
› rustc: 1.62.1
› cargo: 1.62.1
› Rust toolchain: stable-x86_64-pc-windows-msvc

Packages
› @tauri-apps/cli [NPM]: 1.0.5
› @tauri-apps/api [NPM]: 1.0.2
› tauri [RUST]: 1.0.5,
› tauri-build [RUST]: 1.0.4,
› tao [RUST]: 0.12.2,
› wry [RUST]: 0.19.0,

App
› build-type: bundle
› CSP: default-src blob: data: filesystem: ws: http: https: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
› distDir: ../build
› devPath: http://localhost:3000/
› framework: React

App directory structure
├─ .git
├─ node_modules
├─ public
├─ src
└─ src-tauri

Stack trace

no stack trace

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions