Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactoring]: improve the getOptions method in the PopUpService class #1720

Open
BlendiGashi opened this issue Mar 20, 2023 · 0 comments
Open
Assignees

Comments

@BlendiGashi
Copy link

What Version of the library are you using?
[email protected]

When I pass the popup properties to the function authorizeWithPopUp(), the left and top properties are overwritten in the metod getOptions() of PopUpService class.

Example taken from docs where you accept the properties but after you do the overwrite in the getOptions method:
loginWithPopup() {
const somePopupOptions = { width: 500, height: 500, left: 50, top: 50 };

const authOptionsOrNull = /* ... */

this.oidcSecurityService.authorizeWithPopUp(authOptions, somePopupOptions)
.subscribe(({ isAuthenticated, userData, accessToken, errorMessage }) => {
/* ... */
});
}

Method taken from the class PopUpService:
getOptions(popupOptions) {
const popupDefaultOptions = { width: 500, height: 500, left: 50, top: 50 };
const options = { ...popupDefaultOptions, ...(popupOptions || {}) };
const left = this.windowInternal.screenLeft + (this.windowInternal.outerWidth - options.width) / 2;
const top = this.windowInternal.screenTop + (this.windowInternal.outerHeight - options.height) / 2;
options.left = left;
options.top = top;
return Object.entries(options)
.map(([key, value]) => ${encodeURIComponent(key)}=${encodeURIComponent(value)})
.join(',');
}

I want to suggest that if you are passed the top and left properties then to use those properties and if they are not passed to uttilize the calculation that is done now.

@BlendiGashi BlendiGashi changed the title [Refactoring]: improve the getOptions method in the PopUpService class [Bug]: improve the getOptions method in the PopUpService class Mar 23, 2023
@BlendiGashi BlendiGashi changed the title [Bug]: improve the getOptions method in the PopUpService class [Refactoring]: improve the getOptions method in the PopUpService class Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants