diff --git a/mail.js b/mail.js index 80b01f9..49e1bfa 100644 --- a/mail.js +++ b/mail.js @@ -45,11 +45,13 @@ var Store = { var DropDownBase = { instances: {}, + currentVisible: null, componentDidMount: function() { if (!DropDownBase.setBodyListener) { window.addEventListener('click', DropDownBase.hideAll); + window.addEventListener('resize', DropDownBase.repositionCurrent); DropDownBase.setBodyListener = true; } DropDownBase.instances[this.props.id] = this; @@ -59,9 +61,16 @@ var DropDownBase = { for (var i in DropDownBase.instances) DropDownBase.instances[i].hide(); }, + repositionCurrent: function() + { + if (DropDownBase.currentVisible) + DropDownBase.currentVisible[0].showAt(DropDownBase.currentVisible[1], DropDownBase.currentVisible[0].onClose); + }, componentWillUnmount: function() { delete DropDownBase.instances[this.props.id]; + if (DropDownBase.currentVisible[0] == this) + DropDownBase.currentVisible = null; }, getInitialState: function() { @@ -74,6 +83,7 @@ var DropDownBase = { hide: function() { this.setState({ visible: false }); + DropDownBase.currentVisible = null; if (this.onClose) { this.onClose(); @@ -82,12 +92,12 @@ var DropDownBase = { }, showAt: function(el, onClose) { - if (this.onClose) + if (this.onClose && this.onClose != onClose) { this.onClose(); delete this.onClose; } - // TODO: move on window resize + DropDownBase.currentVisible = [ this, el ]; var p = getOffset(el); var left = p.left, top = p.top+el.offsetHeight, calloutLeft = null; this.setState({ visible: true, top: top, left: left, selectedItem: -1 }); @@ -504,12 +514,12 @@ var AccountFolders = React.createClass({ return
{this.props.name} +
{this.props.unreadCount}
{this.props.accountId ? [
,
,
] : null} -
{this.props.unreadCount}