Skip to content

Only open windows externally if window is focused#156

Merged
sergeichestakov merged 1 commit intomainfrom
@sergeichestakov/dont-open-when-not-focused
May 2, 2024
Merged

Only open windows externally if window is focused#156
sergeichestakov merged 1 commit intomainfrom
@sergeichestakov/dont-open-when-not-focused

Conversation

@sergeichestakov
Copy link
Copy Markdown
Contributor

Why

We've gotten some reports of the desktop app randomly opening pages when unfocused and in the background. I have a feeling this is due to some of our "openExternal" logic around redirecting non-Replit pages (or those not supported in the desktop app) to the user's browser instead. I'm not sure why this would be occurring in the background since this should usually only happen by the user clicking links or something triggering window.open but evidently it is. See Slack thread.

What changed

Only open external links in the user's browser if the window is actually focused. This will stop tabs from opening when the app is in the background.

Test plan

  • Open external links by clicking a link or calling window.open in the console when the app is focused -> should still open external links in the browser
  • Should stop getting reports of this happening when the app is unfocused though.

@sergeichestakov sergeichestakov self-assigned this May 1, 2024
@sergeichestakov sergeichestakov requested review from a team, ink404, lunaroyster and szymonkaliski and removed request for a team May 1, 2024 16:48
Copy link
Copy Markdown
Contributor

@szymonkaliski szymonkaliski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is good, but feels like a band-aid, is there any way in which we could know what's actually causing the windows to open randomly?

@sergeichestakov
Copy link
Copy Markdown
Contributor Author

yes definitely a band-aid 😕 Not sure yet but will keep digging

@sergeichestakov sergeichestakov merged commit d03a292 into main May 2, 2024
@sergeichestakov sergeichestakov deleted the @sergeichestakov/dont-open-when-not-focused branch May 2, 2024 14:28
@sergeichestakov
Copy link
Copy Markdown
Contributor Author

corresponding web PR: https://github.com/replit/repl-it-web/pull/43941

@sergeichestakov
Copy link
Copy Markdown
Contributor Author

FYI @szymonkaliski figured it out here: https://github.com/replit/repl-it-web/pull/44658

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants