mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 13:18:15 +02:00
Autofocus new note descriptions in the UI code instead of the mode code (re: #7680)
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user