Enable autofill for the source tag in the changeset panel (#10764)

This commit is contained in:
Kyℓe Hensel
2025-02-13 01:22:50 +11:00
committed by GitHub
parent bd85d31b73
commit 33c68064a6
3 changed files with 19 additions and 1 deletions
+2
View File
@@ -38,6 +38,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
# Unreleased (2.32.0-dev)
#### :sparkles: Usability & Accessibility
* Autocomplete changeset `source` tag with sources of the previous 100 changesets of the user ([#10764], thanks [@k-yle])
* Also show search result for coordinates in `lon/lat` order in search results ([#10720], thanks [@Deeptanshu-sankhwar])
* Allow broken (unclosed) areas to be continued ([#9635], thanks [@k-yle])
#### :scissors: Operations
@@ -68,6 +69,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
[#10747]: https://github.com/openstreetmap/iD/issues/10747
[#10748]: https://github.com/openstreetmap/iD/issues/10748
[#10755]: https://github.com/openstreetmap/iD/issues/10755
[#10764]: https://github.com/openstreetmap/iD/issues/10764
[#10766]: https://github.com/openstreetmap/iD/pull/10766
[@hlfan]: https://github.com/hlfan
[@Deeptanshu-sankhwar]: https://github.com/Deeptanshu-sankhwar
+10
View File
@@ -57,6 +57,7 @@ export function uiChangesetEditor(context) {
if (initial) {
var commentField = selection.select('.form-field-comment textarea');
const sourceField = _fieldsArr.find(field => field.id === 'source');
var commentNode = commentField.node();
if (commentNode) {
@@ -82,6 +83,15 @@ export function uiChangesetEditor(context) {
.call(commentCombo
.data(utilArrayUniqBy(comments, 'title'))
);
// add extra dropdown options to the `source` field
// based on the values used in recent changesets.
const recentSources = changesets
.flatMap((changeset) => changeset.tags.source?.split(';'))
.filter(Boolean)
.map(title => ({ title, value: title, klass: 'raw-option' }));
sourceField.impl.setCustomOptions(utilArrayUniqBy(recentSources, 'title'));
});
}
}
+7 -1
View File
@@ -43,6 +43,7 @@ export function uiFieldCombo(field, context) {
var _tags;
var _countryCode;
var _staticPlaceholder;
var _customOptions = [];
// initialize deprecated tags array
var _dataDeprecated = [];
@@ -181,7 +182,7 @@ export function uiFieldCombo(field, context) {
} else {
options = [].concat(field.options, stringsField.options).filter(Boolean);
}
return options.map(function(v) {
const result = options.map(function(v) {
const labelId = getLabelId(stringsField, v);
return {
key: v,
@@ -191,6 +192,7 @@ export function uiFieldCombo(field, context) {
klass: stringsField.hasTextForStringId(labelId) ? '' : 'raw-option'
};
});
return [...result, ..._customOptions];
}
@@ -926,6 +928,10 @@ export function uiFieldCombo(field, context) {
);
}
combo.setCustomOptions = (newValue) => {
_customOptions = newValue;
};
combo.focus = function() {
_input.node().focus();