FIX: Was refocusing on resize events

This was annoying on small screens in desktop mode, where a keyboard
appearing would refocus on the search bar and make it impossible to
dismiss.
This commit is contained in:
Robin Ward 2015-12-23 15:17:00 -05:00
parent d1ebb9d0b5
commit eab9ad7b27
1 changed files with 8 additions and 2 deletions

View File

@ -6,6 +6,7 @@ const mutationSupport = !Ember.testing && !!window['MutationObserver'];
export default Ember.Component.extend({
classNameBindings: [':menu-panel', 'visible::hidden', 'viewMode'],
_lastVisible: false,
showClose: Ember.computed.equal('viewMode', 'slide-in'),
@ -89,7 +90,11 @@ export default Ember.Component.extend({
_visibleChanged() {
if (this.get('visible')) {
// Allow us to hook into things being shown
Ember.run.scheduleOnce('afterRender', () => this.sendAction('onVisible'));
if (!this._lastVisible) {
Ember.run.scheduleOnce('afterRender', () => this.sendAction('onVisible'));
this._lastVisible = true;
}
$('html').on('click.close-menu-panel', (e) => {
const $target = $(e.target);
if ($target.closest('.header-dropdown-toggle').length > 0) { return; }
@ -103,7 +108,8 @@ export default Ember.Component.extend({
if (!this.capabilities.isIOS) {
$(window).on('scroll.discourse-menu-panel', () => this.performLayout());
}
} else {
} else if (this._lastVisible) {
this._lastVisible = false;
Ember.run.scheduleOnce('afterRender', () => this.sendAction('onHidden'));
$('html').off('click.close-menu-panel');
$(window).off('scroll.discourse-menu-panel');