Autofocus new note descriptions in the UI code instead of the mode code (re: #7680)

This commit is contained in:
Quincy Morgan
2020-06-08 11:42:29 -04:00
parent fd41e5fd75
commit 61b3aaafd2
3 changed files with 14 additions and 7 deletions
+13 -2
View File
@@ -31,6 +31,7 @@ export function uiNoteEditor(context) {
// var formFields = uiFormFields(context);
var _note;
var _newNote;
// var _fieldsArr;
@@ -75,7 +76,6 @@ export function uiNoteEditor(context) {
.call(noteComments.note(_note))
.call(noteSaveSection);
var footer = selection.selectAll('.footer')
.data([0]);
@@ -152,7 +152,7 @@ export function uiNoteEditor(context) {
return _note.isNew() ? t('note.newDescription') : t('note.newComment');
});
noteSaveEnter
var commentTextarea = noteSaveEnter
.append('textarea')
.attr('class', 'new-comment-input')
.attr('placeholder', t('note.inputPlaceholder'))
@@ -163,6 +163,11 @@ export function uiNoteEditor(context) {
.on('input.note-input', changeInput)
.on('blur.note-input', changeInput);
if (_newNote) {
// autofocus the comment field for new notes
commentTextarea.node().focus();
}
// update
noteSave = noteSaveEnter
.merge(noteSave)
@@ -430,6 +435,12 @@ export function uiNoteEditor(context) {
return noteEditor;
};
noteEditor.newNote = function(val) {
if (!arguments.length) return _newNote;
_newNote = val;
return noteEditor;
};
return utilRebind(noteEditor, dispatch, 'on');
}