0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00

Merge pull request #3578 from morficus/issue-3516

Stop event propagation when hitting "enter" in the gh-blur-input component
This commit is contained in:
Hannah Wolfe 2014-08-03 17:25:29 +01:00
commit 27710e88d2
2 changed files with 12 additions and 2 deletions

View file

@ -1,5 +1,6 @@
var BlurInput = Ember.TextField.extend({
selectOnClick: false,
stopEnterKeyDownPropagation: false,
click: function (event) {
if (this.get('selectOnClick')) {
event.currentTarget.select();
@ -7,6 +8,15 @@ var BlurInput = Ember.TextField.extend({
},
focusOut: function () {
this.sendAction('action', this.get('value'));
},
keyDown: function (event) {
// stop event propagation when pressing "enter"
// most useful in the case when undesired (global) keyboard shortcuts are getting triggered while interacting
// with this particular input element.
if (this.get('stopEnterKeyDownPropagation') && event.keyCode === 13) {
event.stopPropagation();
return true;
}
}
});

View file

@ -6,7 +6,7 @@
<label for="url">URL</label>
</td>
<td class="post-setting-field">
{{gh-blur-input class="post-setting-slug" id="url" value=slugValue name="post-setting-slug" action="updateSlug" placeholder=slugPlaceholder selectOnClick="true"}}
{{gh-blur-input class="post-setting-slug" id="url" value=slugValue name="post-setting-slug" action="updateSlug" placeholder=slugPlaceholder selectOnClick="true" stopEnterKeyDownPropagation="true"}}
</td>
</tr>
<tr class="post-setting">
@ -14,7 +14,7 @@
<label for="pub-date">Pub Date</label>
</td>
<td class="post-setting-field">
{{gh-blur-input class="post-setting-date" value=publishedAtValue name="post-setting-date" action="setPublishedAt" placeholder=publishedAtPlaceholder}}
{{gh-blur-input class="post-setting-date" value=publishedAtValue name="post-setting-date" action="setPublishedAt" placeholder=publishedAtPlaceholder stopEnterKeyDownPropagation="true"}}
</td>
</tr>
<tr class="post-setting">