-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Stickerpacks #6242
Stickerpacks #6242
Conversation
} | ||
|
||
componentWillUnmount() { | ||
window.removeEventListener("resize", this.resize.bind(this)); |
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.
You'll probably find this doesn't work since the new bound function you're creating is not equal to the one you created previously.
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 to work, but thanks very much for pointing this out (makes a lot of sense not that you've mentioned it), I've moved the binding to the constructor.
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export default class GenericElementContextMenu extends React.Component { |
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.
A brief comment on what this does might be useful. It appears to tell a child element about window resizes, but I'm not sure what that has to do with context menus.
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.
The position of the contextual menus are set at construction time. If you resize the window while the menu is visible the element that the menu is linked to moves but the menu does not as it is displayed in a DOM element on the document root. By adding a resize listener the menu parent can be triggered to update the position or (in this case) close the menu.
this.state={ | ||
parent, | ||
parentBox: parent.getBoundingClientRect(), | ||
}; |
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.
These don't need to be part of the state, in fact this will cause un unnecessary render after the first one because the state's changing.
Thanks @dbkr - Hopefully those points are addressed now. Can you please take another look? Cheers. |
Stickerpack related UI