Skip to content

[bug] Adding a listener to a child window fires events from the parent window #3302

@XuluWarrior

Description

@XuluWarrior

Describe the bug

If I create a new window from a WebView and attach a listener to it, the events that the listener receives are actually from the parent window.
e.g. if I listen to tauri://move on the child window, the listener fires when the parent window moves.

Reproduction

  1. Run this code in the WebView
  function createWindow() {
    const label = Math.random().toString();
    const webview = new WebviewWindow(label);
    windowMap[label] = webview;
    webview.once('tauri://error', function () {
      onMessage("Error creating new webview")
    });
    webview.listen('tauri://move', event => console.log(event));
  }
  1. Move the child window
  2. Nothing appears in the console logs
  3. Move the parent window
  4. Move events are logged in the console.

Expected behavior

I would expect to see the move events of the child window being logged to the console. Not those of the parent.

Platform and versions

tauri-apps/tauri@next 2b9e6ccc38836b27a3850faa697e845325a3866d

Operating System - Mac OS, version 11.6.2 X64

Node.js environment
  Node.js - 14.18.2
  @tauri-apps/cli - 1.0.0-beta.10
  @tauri-apps/api - 1.0.0-beta.8

Global packages
  npm - 6.14.15
  pnpm - Not installed
  yarn - 1.22.17

Rust environment
  rustc - 1.57.0
  cargo - 1.57.0

Rust environment
  rustup - 1.24.3
  rustc - 1.57.0
  cargo - 1.57.0
  toolchain - stable-x86_64-apple-darwin (default)

App directory structure
/dist
/node_modules
/public
/src-tauri
/src

App
  tauri.rs - 1.0.0-beta.8
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: asset: customprotocol: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../dist
  devPath - http://localhost:5000/
  framework - Svelte

Stack trace

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

priority: 1 highHigh priority bugs/missing features or non-crashing regressionsscope: coreCore packages of Tauritype: bug

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions