-
Notifications
You must be signed in to change notification settings - Fork 111
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
Disable default centering (#47) and improve typings #48
base: main
Are you sure you want to change the base?
Conversation
@@ -24,7 +24,6 @@ class NewWindow extends React.PureComponent { | |||
onBlock: null, | |||
onOpen: null, | |||
onUnload: null, | |||
center: 'parent', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will change a default.
if (typeof center === 'string') { | ||
if (features.width == null || features.height == null) { | ||
console.warn( | ||
'react-new-window: "width" and "height" window features must be present when a center prop is provided.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love that detail.
left: number | ||
top: number | ||
menubar: boolean | ||
toolbar: boolean | ||
scrollbars: boolean | ||
location: boolean | ||
status: boolean | ||
resizable: boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems valid window feature are limited to: popup
, width
, height
, left
, top
, noopener
and noreferrer
. The others are no longer working in modern browser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks pretty good. I will merge and test locally and decide for a release.
So, learning that #47 is easily overcome with
center={false}
(I really, really thought thatreact-new-window
is hardcoded to use some kind of centering), I wanted to improve the quality of life a bit by making centerundefined
at the start.Also, I've added additional attribs to the
IWindowFeatures
interface so that it's clear what attributes go to thefeatures
prop. Referenced fromreact-popout-component
, figured theinterface
could be useful since that library hasn't seen new merged commits in almost a year...Feel free to roast my commit if it means writing even better code. :)