A user switch in a macro that is configured for a different tenant creates an endless loading spinner

Problem

If I switch the user within the SharePoint Document macro or the SharePoint List macro in edit mode and the user is configured to a different (wrong) tenant, I get an endless loading spinner.

Cause

The bug only occurs in a very uncommon setting namely if the tenant has been switched shortly before and the logged-in user doesn't have an account in the tenant currently used. Then the user gets the request for login to SharePoint, which he/she successfully completes.

In this case an existing (cached) token is recognized but unfortunately this is not usable for this tenant.

Solution

The problem is solved after closing and reopening the browser because the cached token is then deleted.