From d54da517d9c58862a576174d1ae5b0c4d67641cb Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 2 Apr 2018 22:50:20 +0200 Subject: [PATCH] FIX: more resilient focus filter or header --- .../javascripts/select-kit/mixins/dom-helpers.js.es6 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6 b/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6 index 2330daa4dc1..52fed1b1eba 100644 --- a/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6 +++ b/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6 @@ -67,13 +67,14 @@ export default Ember.Mixin.create({ // try to focus filter and fallback to header if not present focusFilterOrHeader() { + const context = this; // next so we are sure it finised expand/collapse Ember.run.next(() => { Ember.run.schedule("afterRender", () => { - if (!this.$filterInput().is(":visible")) { - this.$header().focus(); + if (!context.$filterInput() || !context.$filterInput().is(":visible")) { + context.$header().focus(); } else { - this.$filterInput().focus(); + context.$filterInput().focus(); } }); });