Skip to content

Commit

Permalink
created autofocus modifier and applied to message form
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchadwick committed May 15, 2024
1 parent c35b775 commit 7277f85
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/components/new-message-input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@value={{this.message}}
id="new-message-text"
placeholder="Type message here and hit enter"
autofocus="autofocus"
{{autofocus}}
/>
<button type="submit">
Send
Expand Down
3 changes: 3 additions & 0 deletions app/modifiers/autofocus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { modifier } from 'ember-modifier';

export default modifier((element) => element.focus());
15 changes: 15 additions & 0 deletions tests/integration/modifiers/autofocus-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';

module('Integration | Modifier | autofocus', function (hooks) {
setupRenderingTest(hooks);

// Replace this with your real tests.
test('it renders', async function (assert) {
await render(hbs`<div {{autofocus}}></div>`);

assert.ok(true);
});
});

0 comments on commit 7277f85

Please sign in to comment.