question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature Request] Allow for login popup to be refocused

See original GitHub issue

Core Library

MSAL.js v2 (@azure/msal-browser)

Wrapper Library

Not Applicable

Description

Apologies if this is already supported by the library - I can’t seem to find documentation as to how it works (despite being closed as completed in #181)

This is basically the same ask as #181.

Use case

  1. User clicks sign in (application calls loginPopup)
  2. User accidentally or intentionally clicks on the host window, thereby hiding the login popup
  3. User clicks sign in again, host application again calls loginPopup

Current behaviour Nothing happens, since a popup is already open, MSAL throws interaction_in_progress

Desired behaviour The existing window is refocused so that the user is brought back into context

Source

Internal (Microsoft)

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
henrylakecommented, Aug 18, 2022

I had this same issue recently when using meal-react.

As a workaround, you can listen for the “POPUP_OPENED” event. The event returns the popup window in its payload which you can store. In your onClick handler for your sign in button, you can first check if you have a reference to the popup window and if you do, you can focus it which will bring it back to the front.

The code might look something like this:

let popupWindow = null

const callbackId = msalInstance.addEventCallback((message) => {
  if (message.eventType === EventType.POPUP_OPENED) {
    // Save the popup window for focusing later
    popupWindow = message.payload.popupWindow;
  }
});

const signInClickHandler = () => {
  // If the popup window is already open, focus it
  if (popupWindow && !popupWindow.closed && popupWindow.focus) {
    popupWindow.focus();
  } else {
    // Otherwiser open a new popup window
    msalInstance.loginPopup();
  }
}
1reaction
sameeragcommented, Jul 19, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature Request: option to bring window to front when new ... - GitHub
Hi, it would be great if yakyak had a feature that allows it to come to the front of the screen (come into...
Read more >
Built-in mechanism to have a message “pop-up” following a ...
Is there a built-in mechanism to have a message “pop-up” following a successful login to display an information message to the users?
Read more >
Incorrect example in API.txt [#1304286] | Drupal.org
In API.txt, there is an example for Popups.open() which is missing the first argument for "popup". However, I think it would be better...
Read more >
37 Types of Popups to Use on Your Website (the Ultimate ...
That's why OptinMonster created a trigger that allows you to specifically ask users to turn off their AdBlock. That's right, a popup to...
Read more >
Feature request: Provide method to retrieve application “client ...
I have a need to vary the look and feel and functionality of the Universal Login Page based on which client the user...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found