It seems like you want to return the user back to the page where they tried to sign in and I am guessing the sign in page is variable.
In the sign in page when you initialize the signInButton, append the following to your configuration:
{
widgetUrl: '/widget?signInSuccessUrl='+encodeURIComponent(window.location.href),
...
}
When the user tries to log in, it will take them to /widget?signInSuccessUrl=xxxxxxxxx&mode=select
After the user successfully logs in, it will take them back to the first page where the sign in flow started overriding the required signInSuccessUrl in the widget page configuration.
You can also modify the query parameter from the default value "signInSuccessUrl" by specifying it in the configuration on the widget page: queryParameterForSignInSuccessUrl: 'yourCustomSignInSuccessUrlQueryParameter'. If you do so, make sure you update the link in your sign in button config.
Hopefully that answers your question.