Skip to content

Commit b7b1560

Browse files
committed
add empty item and preselect it if country detection doesn't work
1 parent 19752a2 commit b7b1560

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

services/static-webserver/client/source/class/osparc/auth/ui/RequestAccount.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,21 @@ qx.Class.define("osparc.auth.ui.RequestAccount", {
129129
rich: true
130130
});
131131
country.add(cItem);
132-
})
132+
});
133+
// preselect
133134
fetch("https://ipapi.co/json")
134135
.then(res => res.json())
135136
.then(data => {
136137
const countryFound = country.getSelectables().find(c => c.getModel().toUpperCase() === data.country_code.toUpperCase());
137138
if (countryFound) {
138139
country.setSelection([countryFound])
139140
}
141+
})
142+
.catch(err => {
143+
console.error(err);
144+
const emptyItem = new qx.ui.form.ListItem("", null, "");
145+
country.add(emptyItem);
146+
country.setSelection([emptyItem]);
140147
});
141148
this._form.add(country, this.tr("Country"), null, "country");
142149

0 commit comments

Comments
 (0)