From 8f5120150c94a9309f8058ddcdf9054a56ff0bad Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Fri, 30 Jan 2015 22:18:26 +0000 Subject: [PATCH] Do not add autofocus attribute unless set to focus No Issue - Don't add the "autofocus" attribute to the input element unless the "focus" property is set to true. --- ghost/admin/components/gh-trim-focus-input.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ghost/admin/components/gh-trim-focus-input.js b/ghost/admin/components/gh-trim-focus-input.js index 4e69b7c36b..c6873628eb 100644 --- a/ghost/admin/components/gh-trim-focus-input.js +++ b/ghost/admin/components/gh-trim-focus-input.js @@ -5,16 +5,20 @@ var TrimFocusInput = Ember.TextField.extend({ attributeBindings: ['autofocus'], autofocus: Ember.computed(function () { - return (device.ios()) ? false : 'autofocus'; + if (this.get('focus')) { + return (device.ios()) ? false : 'autofocus'; + } + + return false; }), - setFocus: function () { + didInsertElement: function () { // This fix is required until Mobile Safari has reliable // autofocus, select() or focus() support - if (this.focus && !device.ios()) { + if (this.get('focus') && !device.ios()) { this.$().val(this.$().val()).focus(); } - }.on('didInsertElement'), + }, focusOut: function () { var text = this.$().val();