mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
Press return to choose the first list item in search-to-add field
This commit is contained in:
@@ -674,6 +674,10 @@ button.add-note svg.icon {
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
.search-add .list-item button.choose:hover,
|
||||
.search-add .list-item button.choose:focus {
|
||||
background: #E6ECFF;
|
||||
}
|
||||
.search-add .list-item button.choose.disabled {
|
||||
background-color: #ececec;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ export function uiPresetList(context) {
|
||||
var value = search.property('value');
|
||||
if (d3_event.keyCode === 13 && value.length) {
|
||||
list.selectAll('.preset-list-item:first-child')
|
||||
.each(function(d) { d.choose.call(d3_select(this).node()); });
|
||||
.each(function(d) { d.choose.call(this); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,18 @@ export function uiSearchAdd(context) {
|
||||
.attr('placeholder', t('modes.add_feature.title'))
|
||||
.attr('type', 'search')
|
||||
.call(utilNoAuto)
|
||||
.on('keypress', function() {
|
||||
// enter/return
|
||||
if (d3_event.keyCode === 13) {
|
||||
popover.selectAll('.list > .list-item:first-child button.choose')
|
||||
.each(function(d) { d.choose.call(this); });
|
||||
d3_event.preventDefault();
|
||||
d3_event.stopPropagation();
|
||||
}
|
||||
})
|
||||
.on('focus', function() {
|
||||
search.attr('focusing', true);
|
||||
search.node().setSelectionRange(0, search.property('value').length);
|
||||
search.attr('focusing', true);
|
||||
popover.classed('hide', false);
|
||||
})
|
||||
.on('blur', function() {
|
||||
@@ -52,8 +61,8 @@ export function uiSearchAdd(context) {
|
||||
})
|
||||
.on('click', function() {
|
||||
if (search.attr('focusing')) {
|
||||
search.attr('focusing', null);
|
||||
search.node().setSelectionRange(0, search.property('value').length);
|
||||
search.attr('focusing', null);
|
||||
d3_event.preventDefault();
|
||||
d3_event.stopPropagation();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user