Skip to content

Commit

Permalink
[BUG] enter key on form for GeoBookmark #700
Browse files Browse the repository at this point in the history
  • Loading branch information
Viglino committed Nov 16, 2021
1 parent 0b01a14 commit 3fbfae7
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/control/GeoBookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,21 @@ var ol_control_GeoBookmark = function(options) {
menu.appendChild(ul);
var input = document.createElement('input');
input.setAttribute("placeholder", options.placeholder || "Add a new geomark...")
input.addEventListener("change", function() {
var title = this.value;
if (title) {
self.addBookmark(title);
this.value = '';
self.dispatchEvent({
type: "add",
name: title
});
input.addEventListener("keydown", function(e) {
e.stopPropagation();
if (e.keyCode === 13) {
e.preventDefault();
var title = this.value;
if (title) {
self.addBookmark(title);
this.value = '';
self.dispatchEvent({
type: "add",
name: title
});
}
menu.style.display = 'none';
}
menu.style.display = 'none';
});
input.addEventListener("blur", function() {
menu.style.display = 'none';
Expand Down Expand Up @@ -149,7 +153,8 @@ ol_control_GeoBookmark.prototype.setBookmarks = function(bmark) {
if (modify && !bmark[b].permanent) {
var button = document.createElement('button');
button.setAttribute('data-name', b);
button.setAttribute("title", "Suppr.");
button.setAttribute('type', 'button');
button.setAttribute('title', 'Suppr.');
button.addEventListener('click', function(e) {
self.removeBookmark(this.getAttribute("data-name"));
self.dispatchEvent({ type: "remove", name: this.getAttribute("data-name") });
Expand Down

0 comments on commit 3fbfae7

Please sign in to comment.