Skip to content

Commit

Permalink
fix(search): add preventDefault to submit
Browse files Browse the repository at this point in the history
Enter inside a text-input submits the form which is a problem.
  • Loading branch information
fkm-adfinis committed Feb 9, 2021
1 parent 73614ee commit 042d24d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion addon/components/search.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<div class="uk-background-muted uk-padding-small uk-border-bottom">
<div
class="uk-background-muted uk-padding-small uk-border-bottom"
{{on "submit" this.onSubmit}}
>
<form class="uk-background-default uk-search uk-search-default uk-width-1">
<a href="" uk-search-icon></a>
<input
Expand Down
5 changes: 5 additions & 0 deletions addon/components/search.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import Component from "@glimmer/component";
import { timeout } from "ember-concurrency";
Expand All @@ -6,6 +7,10 @@ import { restartableTask } from "ember-concurrency-decorators";
export default class SearchComponent extends Component {
@service router;

@action onSubmit(event) {
event.preventDefault();
}

@restartableTask *updateSearch({ target: { value: search } }) {
if (!Ember.testing) {
yield timeout(1000);
Expand Down

0 comments on commit 042d24d

Please sign in to comment.