mattermost / desktop

Mattermost Desktop application for Windows, Mac and Linux
Apache License 2.0
2.03k stars 829 forks source link

Plugin support for popup/dialog windows with external URL or content. Window focus issue. #2534

Closed catz closed 1 year ago

catz commented 1 year ago

I confirm (by marking "x" in the [ ] below: [x]):


Show (focus on) already opened popup on url change. It's hard to understand what's going on when main app is in fullscreen and popup is in background.

Environment

Steps to reproduce

  1. Plugin (right panel in our case) opens some url. Popup gets focus.
  2. Go back to main app. Popup is in background
  3. Plugin opens another url. Some intentional user action like user clicked another button.

Expected behavior

Popup gets focus.

Observed behavior

Popup is in background.

Possible fixes

Change line https://github.com/mattermost/desktop/blob/master/src/main/views/webContentEvents.ts#L195

From

this.popupWindow.once('ready-to-show', () => {

to

this.popupWindow.on('ready-to-show', () => {

devinbinnie commented 1 year ago

@catz Can you give an example where plugins should be doing this? The current behaviour of the Desktop App is to not open another popup (or a plugin URL in the same popup window) so I can't see where this would be happening.

catz commented 1 year ago

Hello Devin,

I will try to explain.

  1. User opens the right panel and clicks info on some event img1
  2. MM opens new BrowserWindow img2
  3. User returns to main MM window. MM main window becomes on top of child window.
  4. User clicks on another event.
  5. Child's window content gets updated but the child window itself stays behind the main MM window. It doesn't receive focus because 'ready-to-show' event happens only once.

Can't say it's a big issue but imho fix seems very trivial.

devinbinnie commented 1 year ago

@catz Which plugin are you using here?

catz commented 1 year ago

@devinbinnie this is our own (work in progress) plugin.

devinbinnie commented 1 year ago

@catz I've made a change that should address your issue: https://github.com/mattermost/desktop/pull/2581 There will be a build generated shortly, can you test and make sure it works for you?