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]: Linux: Double actions when handling app-command handlers: browser-backward and browser-forward #18322 #32763

Open
3 tasks done
LunNova opened this issue Feb 6, 2022 · 38 comments
Labels
20-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/linux

Comments

@LunNova
Copy link

LunNova commented Feb 6, 2022

Preflight Checklist

Electron Version

Confirmed to impact these versions:

16, v17.0.0, v20.1.0

Probably impacts all versions in between.

What operating system are you using?

Other Linux

Operating System Version

Linux lun-hisame-nixos 5.15.19-xanmod1-tt #1-NixOS SMP PREEMPT Tue Jan 1 00:00:00 UTC 1980 x86_64 GNU/Linux

What arch are you using?

x64

Last Known Working Electron version

4

Expected Behavior

When pressing back/forward mouse buttons on linux, either app command events should be created OR they should be automatically handled and cause navigation.

Two suggested approaches:

  • To match Windows behaviour, we should emit app-command events and not cause navigation.
  • To minimise breakage of existing Linux apps that don't handle app-command, app-command events should not be emitted and the navigation should still be done automatically

Actual Behavior

When the mouse side buttons are used, app command events are created AND navigation is automatically done so if an app handles the app-command events per the documentation then navigation will happen twice.

#15441 added support for app-command handlers: browser-backward and browser-forward on Linux.

The docs describe how to make use of these here:
https://github.com/electron/electron/blob/v5.0.1/docs/api/browser-window.md#event-app-command-windows-linux

Our code is very similar here, and has been in place to support windows for years:
https://github.com/irccloud/irccloud-desktop/blob/master/app/main.js#L293-L311

When testing this on Ubuntu 19.04, this results in back and forward actions being triggered twice when using the appropriate mouse buttons.

Testcase Gist URL

https://gist.github.com/LunNova/a4c61b7082d17b8aa637217f763348bf

Additional Information

A previous ticket was closed #18322 but this is still a problem. I have asked for it to be reopened, but noone seems to have seen that.

Related third party ticket https://support.discord.com/hc/en-us/community/posts/1500000622702-Thumb-mouse-button-on-Linux-registers-twice

@mlaurencin
Copy link
Contributor

Thanks for reporting this and helping to make Electron better!

Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, Electron Fiddle is a great tool for making small test cases and makes it easy to publish your test case to a gist that Electron maintainers can use. If you take the code from either of the examples you provided and the issue replicable in the Fiddle Gist, that will helpful.

Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.

I'm adding the blocked/need-repro label for this reason. After you make a test case, please link to it in a follow-up comment.

@mlaurencin mlaurencin added 16-x-y blocked/need-repro Needs a test case to reproduce the bug platform/linux labels Feb 8, 2022
@LunNova
Copy link
Author

LunNova commented Feb 8, 2022

@mlaurencin

index.js

const {app, BrowserWindow} = require('electron');

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') app.quit()
})
app.whenReady().then(async () => {
  let mainWindow = new BrowserWindow({height: 600, width: 600});
  // Handle app command per docs except also refresh and forward
  // https://www.electronjs.org/docs/latest/api/browser-window/#event-app-command-windows-linux
  mainWindow.on('app-command', function (e, cmd) {
    switch (cmd) {
    case 'browser-backward':
      if (mainWindow.webContents.canGoBack()) {
        mainWindow.webContents.goBack();
      }
      break;
    case 'browser-forward':
      if (mainWindow.webContents.canGoForward()) {
        mainWindow.webContents.goForward();
      }
      break;
    case 'browser-refresh':
      mainWindow.webContents.reloadIgnoringCache();
      break;
    default:
      break;
    }
  });
  for (var i = 0; i <= 10; i++) {
    await mainWindow.loadURL("data:text/plain;," + i + "/10");
  }
});

On Windows: back/forward button presses will go back/forward one page at a time
On Linux: back/forward button presses will go back/forward two pages instead (once when button is pressed and once when released)

@LunNova
Copy link
Author

LunNova commented Feb 8, 2022

@mlaurencin mlaurencin added has-repro-gist Issue can be reproduced with code at https://gist.github.com/ and removed blocked/need-repro Needs a test case to reproduce the bug labels Feb 16, 2022
@hjkatz
Copy link

hjkatz commented May 16, 2022

I'm experiencing this issue with Slack's snap on Ubuntu 22.04 as well.

name:      slack
summary:   Team communication for the 21st century.
publisher: Slack✓
store-url: https://snapcraft.io/slack
contact:   https://get.slack.help/hc/en-us
license:   unset
description: |
Caution: Slack for Linux is in beta. We’re still busy adding features and ironing out potential
issues.

Slack brings team communication and collaboration into one place so you can get more work done,
whether you belong to a large enterprise or a small business. Check off your to-do list and move
your projects forward by bringing the right people, conversations, tools, and information you need
together. Slack is available on any device, so you can find and access your team and your work,
whether you’re at your desk or on the go.

Scientifically proven (or at least rumored) to make your working life simpler, more pleasant, and
more productive. We hope you’ll give Slack a try.

Stop by and learn more at: https://slack.com/
commands:
- slack
snap-id:      JUJH91Ved74jd4ZgJCpzMBtYbPOzTlsD
tracking:     latest/stable
refresh-date: 6 days ago, at 13:49 EDT
channels:
latest/stable:     4.25.1 2022-04-04 (61) 108MB -
latest/candidate:  ↑
latest/beta:       ↑
latest/edge:       ↑
insider/stable:    –
insider/candidate: –
insider/beta:      –
insider/edge:      4.25.1 2022-04-01 (61) 108MB -
installed:           4.25.1            (61) 108MB -

@lmcarreiro
Copy link

I'm experiencing this issue with Slack's snap on Ubuntu 22.04 as well.

Same here, very annoying bug!

If I install Slack from another source instead of snap, would we have the same issue?

@hjkatz
Copy link

hjkatz commented Jun 17, 2022

No, I've tried both versions and it seems to be a problem with Slack's imported version of Electron. I also reached out to Slack support and they said they were aware of the problem, but gave no timeline for an intended fix.

@diniamo
Copy link

diniamo commented Jul 26, 2022

I have this issue on Discord as well.

@edoardopirovano
Copy link

Also experiencing this on Slack in Ubuntu 22.04.

@rneatherway
Copy link

Same here. Is there any way that we could move the discussion forward on which solution might be workable?

To match Windows behaviour, we should emit app-command events and not cause navigation.
To minimise breakage of existing Linux apps that don't handle app-command, app-command events should not be emitted and the navigation should still be done automatically

@MarshallOfSound might you have an opinion? I ask as you reviewed #15441 and your profile indicates that you work at Slack right now.

@JFGHT
Copy link

JFGHT commented Sep 23, 2022

Bump on this.

In the meanwhile you can use the keyboard shortcut: ALT + LEFT.

@LunNova
Copy link
Author

LunNova commented Sep 23, 2022

Tested again on electron v20.1.0, still reproduces. Can we get the labels updated @mlaurencin ?

@AddisonG
Copy link

Still getting this in Slack (v4.28.171) on Ubuntu 20.04, and have had this for a few years now.

@mennoxx
Copy link

mennoxx commented Oct 25, 2022

No, I've tried both versions and it seems to be a problem with Slack's imported version of Electron. I also reached out to Slack support and they said they were aware of the problem, but gave no timeline for an intended fix.

Thats what they already said, when I reported the issue to Slack 2 years ago unfortunately.. I don't expect them to fix this anymore while it still annoyes me every single day.

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Jan 24, 2023
@wbollock
Copy link

bump 🙏

@LunNova
Copy link
Author

LunNova commented Jan 24, 2023

It's still broken.

@lmcarreiro
Copy link

lmcarreiro commented Jan 24, 2023

Very annoying issue. I'm getting on Slack 4.29.149 64-bit Ubuntu 22.04

@TomerGodinger
Copy link

Yes, still happening and immensely frustrating.

@naclonts
Copy link

Happening for me on Slack Debian 11, as well.

@dsanders11 dsanders11 changed the title Linux: Double actions when handling app-command handlers: browser-backward and browser-forward #18322 [Bug]: Linux: Double actions when handling app-command handlers: browser-backward and browser-forward #18322 Apr 4, 2023
@jason-h-35
Copy link

bump

@kznrluk
Copy link

kznrluk commented Apr 18, 2023

bump, Slack desktop on Arch linux and XFCE4.

@alangalvino
Copy link

bump

@IrrerPolterer
Copy link

Still experiencing the issue in Slack.
Mouse-Back and Mouse-Forward each register twice (on button press and release)

@CAS-14
Copy link

CAS-14 commented May 16, 2023

Experiencing this issue with WebCatalog on Linux.

@BinaryVixen899
Copy link

Still experienceing this with the Slack app in Ubuntu 23.04

@jonathan-saindon
Copy link

jonathan-saindon commented Jun 21, 2023

I am experiencing this as well on Mint 21.1 with kernel 5.15.0-73-generic. Currently using Slack version 4.32.127 64-bit

@mpearson
Copy link

Seeing this bug on Ubuntu 18.04 as well as 22.04. Slack version 4.32.127 64-bit. Extremely annoying. I have several other Electron apps which do not have this problem, e.g. VS Code and Discord, so presumably it's just an electron version issue?

@ReillyBrogan
Copy link

Seeing this bug on Ubuntu 18.04 as well as 22.04. Slack version 4.32.127 64-bit. Extremely annoying. I have several other Electron apps which do not have this problem, e.g. VS Code and Discord, so presumably it's just an electron version issue?

Most likely the apps that do not have this issue are explicitly ignoring either the app-command events or the navigation events.

@wugaosheng123
Copy link
Contributor

wugaosheng123 commented Aug 25, 2023

hello @codebytere
I think this is a problem with the example code in the docs. browser-backward and browser-forward events are handled by default to navigate the page, so shouldn't have to perform win.webContents.goBack() in win.on('app-command', (e, cmd)......, or else clicking the mouse button once navigates the page twice.

图片

But I didn't find the default handing of browser-backward and browser-forward in electron's code (which performs the navigation of the page), and I'm guessing this is done by chromium.If so, is this issure meaningless?Because browser-backward and browser-forward already has a default action, unless he is told to perform another behavior instead of doing page navigation

I would be more than happy to submit a pr for this

@shawn-mccool-mollie
Copy link

Is there any work around? We have many people using slack and this is a significant usability issue.

@TaylorMichaelHall
Copy link

TaylorMichaelHall commented Sep 20, 2023

Is there any work around? We have many people using slack and this is a significant usability issue.

The keyboard shortcuts work. Another option on Linux is to use the Slack webapp instead of the desktop app - the back/forward mouse buttons work there for me.

@lsaintier
Copy link

Today my compagny rollout a new slack release and it's still there. I can't believe it's still not fixed.

@alangalvino
Copy link

Still experiencing the issue in Slack.

@MKimiSH
Copy link

MKimiSH commented Oct 18, 2023

One workaround for Slack (works on Ubuntu 22.04) with an additional right click:

  1. Find a place where right click calls out a text editing menu from the system (Copy/Paste/Cut or just Copy), not the one from Slack (Add reaction, reply in thread, etc.). I usually do it on the blank area to the right of the channel title.
  2. Right click in that region, and see the copy-paste menu pop-up.
  3. Move the cursor to be still in Slack but outside the copy-paste menu. This is important, because when we click forward/backward when the cursor is in the menu, nothing happens (at least for me).
  4. Click forward/backward. This should only move forward/backward by one page, not two.

@eizieizi
Copy link

itsdanomano found a temporary solution for the issue (posted on reddit), but it has to be re-done after every app update.
https://www.reddit.com/r/Slack/comments/qfodd7/when_i_press_back_on_a_mouse_in_the_slack_app_on/

Also for Snap its not so easy as the snap files are read only. Maybe one could work arround the issue with file mounts.

@vtushevskiyNV
Copy link

itsdanomano found a temporary solution for the issue (posted on reddit), but it has to be re-done after every app update. https://www.reddit.com/r/Slack/comments/qfodd7/when_i_press_back_on_a_mouse_in_the_slack_app_on/

Also for Snap its not so easy as the snap files are read only. Maybe one could work arround the issue with file mounts.

doesn't work for me

@genka-pokos
Copy link

itsdanomano found a temporary solution for the issue (posted on reddit), but it has to be re-done after every app update. https://www.reddit.com/r/Slack/comments/qfodd7/when_i_press_back_on_a_mouse_in_the_slack_app_on/
Also for Snap its not so easy as the snap files are read only. Maybe one could work arround the issue with file mounts.

doesn't work for me

Try the command from the mythin's message. Works for me

@marcodiiga
Copy link

I also would love to see this fixed: I must reapply the reddit fix each time slack gets updated unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
20-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/ platform/linux
Projects
None yet
Development

No branches or pull requests