mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 19:48:50 +03:00
Stop event propagation when hitting "enter" in the gh-blur-input component
fixes #3516 - new behavior is disabled by default - added new stopEnterKeyDownPropagation property enable new behavior
This commit is contained in:
parent
ec1dc0e24a
commit
8aef67ef52
@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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">
|
||||
|
Loading…
Reference in New Issue
Block a user