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] Child window failed to show if main window is not visible initially hidden #9286

Closed
selastingeorge opened this issue Mar 27, 2024 · 1 comment · Fixed by #9100
Closed
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@selastingeorge
Copy link

Describe the bug

In the tauri.config.json file, if the visible attribute is set to false, and subsequently, the window is displayed using the show() method within the setup() hook, calling a Tauri command to create a child window results in the child window appearing and disappearing automatically.

The child window shows normally if visible is set to true for mainwindow.

Part of tauri.config.json is given below:

"app": {"windows": [
      {
        "title": "childwindow-test",
        "width": 800,
        "height": 600,
        "visible": false
      }
    ],
    "security": {
      "csp": null
    }
  },

In main.rs file:

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use tauri::{AppHandle, Manager};

#[tauri::command]
async fn open_docs(handle: tauri::AppHandle) {
  let docs_window = tauri::WebviewWindowBuilder::new(
    &handle,
    "external", /* the unique window label */
    tauri::WebviewUrl::External("https://tauri.app/".parse().unwrap())
  ).build().unwrap();
}

fn main() {
    tauri::Builder::default()
        .setup(|app|{
            let mainwindow = app.get_webview_window("main").unwrap();
            mainwindow.show();
            Ok(())
        })
        .plugin(tauri_plugin_shell::init())
        .invoke_handler(tauri::generate_handler![open_docs])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

In Angular code, i invoke the command using:

import { invoke } from "@tauri-apps/api/core";
async openWindow() {
    await invoke("open_docs").then(()=>{
        console.log("Window Created");
    });
}

Reproduction

To reproduce the bug, follow these steps:

  • Set visible to false in tauri.config.json
  • Show the main window again using show() method from WebviewWindow
  • Create a tauri command to create a child window.
  • Call the tauri command from the front end.

Sample project to reproduce the issue : https://github.com/selastingeorge/childwindow-test
Example code taken from (Modified for Tauri v2 support): https://tauri.app/v1/guides/features/multiwindow/

Expected behavior

The child window should be displayed along with main window.

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22631 X64
    ✔ WebView2: 122.0.2365.92
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.77.0 (aedd173a2 2024-03-17)
    ✔ cargo: 1.77.0 (3fe68eabf 2024-02-29)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.11.0
    - npm: 10.2.4

[-] Packages
    - tauri [RUST]: 2.0.0-beta.13
    - tauri-build [RUST]: 2.0.0-beta.10
    - wry [RUST]: 0.37.0
    - tao [RUST]: 0.26.2
    - @tauri-apps/api [NPM]: 2.0.0-beta.6
    - @tauri-apps/cli [NPM]: 2.0.0-beta.11

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist/childwindow-test/browser
    - devUrl: http://localhost:1420/
    - framework: Angular
    - bundler: Webpack

Stack trace

No response

Additional context

No response

@selastingeorge selastingeorge added status: needs triage This issue needs to triage, applied to new issues type: bug labels Mar 27, 2024
@selastingeorge selastingeorge changed the title Child window failed to show if main window is not visible initially hidden [bug] [bug] Child window failed to show if main window is not visible initially hidden Mar 27, 2024
@amrbashir
Copy link
Member

fixed in #9100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants