diff --git a/app/components/api-token-row.js b/app/components/api-token-row.js index 9c628e44148..eb8255a63ef 100644 --- a/app/components/api-token-row.js +++ b/app/components/api-token-row.js @@ -7,9 +7,8 @@ export default Component.extend({ serverError: null, didInsertElement() { - let input = this.element.querySelector('input'); - if (input.focus) { - input.focus(); + if (this.get('api_token.isNew')) { + this.$('input').focus(); } }, diff --git a/app/templates/components/api-token-row.hbs b/app/templates/components/api-token-row.hbs index 03ad410e751..8eeaf0a4dfa 100644 --- a/app/templates/components/api-token-row.hbs +++ b/app/templates/components/api-token-row.hbs @@ -6,10 +6,8 @@ placeholder="New token name" disabled=api_token.isSaving value=api_token.name - autofocus="autofocus" - enter="saveToken" - data-test-focused-input=true - }} + autofocus=true + enter="saveToken"}} {{else}} {{ api_token.name }} {{/if}} diff --git a/tests/integration/components/api-token-row-test.js b/tests/integration/components/api-token-row-test.js deleted file mode 100644 index e02f4469acd..00000000000 --- a/tests/integration/components/api-token-row-test.js +++ /dev/null @@ -1,19 +0,0 @@ -import { module, test } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; -import { render } from '@ember/test-helpers'; -import hbs from 'htmlbars-inline-precompile'; - -module('Integration | Component | api-token-row', function(hooks) { - setupRenderingTest(hooks); - - test('input is focused if token is new', async function(assert) { - // Set any properties with this.set('myProperty', 'value'); - // Handle any actions with this.set('myAction', function(val) { ... }); - this.set('api_token', { - isNew: true, - }); - - await render(hbs`{{api-token-row api_token=api_token}}`); - assert.dom('[data-test-focused-input]').isFocused(); - }); -});