diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9aa9a2165..066e0c957 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -41,6 +41,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
# Unreleased
#### :newspaper: News
+<<<<<<< HEAD
#### :tada: New Features
* Consider lifecycle prefixes when deciding whether features should be rendered as a line or an area ([#8881], thanks [@k-yle])
#### :white_check_mark: Validation
@@ -102,6 +103,9 @@ _Breaking developer changes, which may affect downstream projects or sites that
##### 2022-Jun-03
#### :newspaper: News
+=======
+
+>>>>>>> Fix iD using invalid user selected imagery
* Drop legacy support for Internet Explorer 11 ([#8811])
* Use OAuth2 for authentication with OSM API ([#9134], thanks [@bhousel] and [@dakotabenjamin])
#### :white_check_mark: Validation
@@ -111,8 +115,12 @@ _Breaking developer changes, which may affect downstream projects or sites that
* Fix KeepRight warnings showing up as "Unknown" issues ([#8925])
* Fix ⌥W keyboard shortcut not working on MacOS in certain system languages / keyboard layouts (e.g. Spanish) ([#8905])
* Render closed ways tagged as `public_transport=platform`, `waterway=dam` or `highway=elevator` as areas ([#8985])
+<<<<<<< HEAD
* Fix a bug which caused validations to not take effect in certain situations ([#9021], thanks [@mbrzakovic])
* Properly escape currently logged-in user's user name ([#9097], thanks [@jleedev])
+=======
+* Fix iD using invalid user selected imagery ([#8732])
+>>>>>>> Fix iD using invalid user selected imagery
#### :rocket: Presets
* Optimize order of values in dropdowns of `access` fields ([#8945])
* Use value of `vehicle` tag as placeholder value of `access` fields for `motor_vehicle` and `bicycle`
diff --git a/modules/renderer/background.js b/modules/renderer/background.js
index b293c6e5f..09b267b8a 100644
--- a/modules/renderer/background.js
+++ b/modules/renderer/background.js
@@ -459,11 +459,13 @@ export function rendererBackground(context) {
return _loadPromise = ensureImageryIndex()
.then(imageryIndex => {
- const first = imageryIndex.backgrounds.length && imageryIndex.backgrounds[0];
+ const validBackgrounds = background.sources(extent);
+ const first = validBackgrounds.length && validBackgrounds[0];
+ const isRequestedValid = !!validBackgrounds.find(d => d.id && d.id === requested);
let best;
- if (!requested && extent) {
- best = background.sources(extent).find(s => s.best());
+ if (!isRequestedValid || (!requested && extent)) {
+ best = validBackgrounds.find(s => s.best());
}
// Decide which background layer to display
@@ -473,14 +475,22 @@ export function rendererBackground(context) {
background.baseLayerSource(custom.template(template));
prefs('background-custom-template', template);
} else {
- background.baseLayerSource(
- background.findSource(requested) ||
- best ||
- background.findSource(prefs('background-last-used')) ||
+ const defaultSource = (
background.findSource('Bing') ||
first ||
background.findSource('none')
);
+
+ if (!isRequestedValid) {
+ background.baseLayerSource(best || defaultSource);
+ } else {
+ background.baseLayerSource(
+ background.findSource(requested) ||
+ best ||
+ background.findSource(prefs('background-last-used')) ||
+ defaultSource
+ );
+ }
}
const locator = imageryIndex.backgrounds.find(d => d.overlay && d.default);