mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 05:30:35 +02:00
Autofocus new note descriptions in the UI code instead of the mode code (re: #7680)
This commit is contained in:
@@ -34,10 +34,6 @@ export function modeAddNote(context) {
|
||||
context
|
||||
.selectedNoteID(note.id)
|
||||
.enter(modeSelectNote(context, note.id).newFeature(true));
|
||||
|
||||
// autofocus the description field
|
||||
context.container()
|
||||
.select('.sidebar textarea.new-comment-input').node().focus();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ export function modeSelectNote(context, selectedNoteID) {
|
||||
selectNote();
|
||||
|
||||
var sidebar = context.ui().sidebar;
|
||||
sidebar.show(_noteEditor.note(note));
|
||||
sidebar.show(_noteEditor.note(note).newNote(_newFeature));
|
||||
|
||||
// expand the sidebar, avoid obscuring the note if needed
|
||||
sidebar.expand(sidebar.intersects(note.extent()));
|
||||
|
||||
@@ -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