tauri: [bug] Mouse back/forward doesnt work on linux

Describe the bug

Mouse navigation buttons (back and forward) does nothing on linux and are registered as mouse left click.

Reproduction

  1. Create new vanilla js app with npx create-tauri-app, select vanilla js
  2. Replace index.html with this:
<!DOCTYPE html>
<html>
  <style>
    html,
    body {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
    }

    body {
      display: flex;
      align-items: center;
      justify-content: center;
    }
  </style>
    <script>
      window.addEventListener('mousedown', event => {
        document.getElementById('button-id').innerHTML = 'Button id: ' + event.button.toString()
      })
    </script>
  <body>
    <h1>history-api</h1>
    <a href="https://tauri.studio">Tauri webpage</a>
    <button onclick="window.history.back()">Back</button>
    <button onclick="window.history.forward()">Forward</button>

    <p id="button-id"></p>
  </body>
</html>
  1. Press different mouse button to see the id
  2. Click the link and use mouse buttons to navigate back/forward
  3. You can also test with the buttons on page how history should work

Expected behavior

Page should navigate between the external website and our index.html and mouse back/forward buttons should not be detected as mouse left (id 0).

Platform and versions

Environment
  › OS: Arch Linux Rolling Release X64
  › Node.js: 17.9.0
  › npm: 8.5.5
  › pnpm: 7.0.0
  › yarn: 1.22.18
  › rustup: 1.24.3
  › rustc: 1.60.0
  › cargo: 1.60.0
  › Rust toolchain: stable-x86_64-unknown-linux-gnu 

Packages
  › @tauri-apps/cli [NPM]: 1.0.0-rc.9
  › @tauri-apps/api [NPM]: 1.0.0-rc.4
  › tauri [RUST]: 1.0.0-rc.8,
  › tauri-build [RUST]: 1.0.0-rc.7,
  › tao [RUST]: 0.8.3,
  › wry [RUST]: 0.15.1,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: ../dist

App directory structure
  ├─ dist
  ├─ node_modules
  └─ src-tauri

Stack trace

No response

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 19 (13 by maintainers)

Most upvoted comments

While back/forward works in epiphany, the event is still not triggered. I can make mouse back/forward buttons navigate back and forward but the event won’t be emitted, eg window.addEventListener('mousedown') won’t work. I am still exploring options but I think I am very close to fixing this.

It does fire on chromium based browsers so I think I can synthesize the events, will let you know if it goes well. The good news is that I can make the back/forward navigation work anyways.