From b4dcfec86e84dfda157128f25aaf9d4ece3c27cd Mon Sep 17 00:00:00 2001 From: floookay <33830863+floookay@users.noreply.github.com> Date: Thu, 3 Oct 2019 13:36:10 +0200 Subject: [PATCH] changed select eventListeners from "input" to "change" (#318) Although not an issue for most modern browsers, Microsoft Edge does not register "input" events on select Elements. Bugfix for issue #315. https://github.com/Azgaar/Fantasy-Map-Generator/issues/315 --- modules/ui/provinces-editor.js | 2 +- modules/ui/religions-editor.js | 2 +- modules/ui/states-editor.js | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/ui/provinces-editor.js b/modules/ui/provinces-editor.js index 80b57343..09d85cf6 100644 --- a/modules/ui/provinces-editor.js +++ b/modules/ui/provinces-editor.js @@ -45,7 +45,7 @@ function editProvinces() { if (cl.contains("icon-trash-empty")) removeProvince(p); }); - body.addEventListener("input", function(ev) { + body.addEventListener("change", function(ev) { const el = ev.target, cl = el.classList, line = el.parentNode, p = +line.dataset.id; if (cl.contains("cultureBase")) changeCapital(p, line, el.value); }); diff --git a/modules/ui/religions-editor.js b/modules/ui/religions-editor.js index f29503db..a5a23540 100644 --- a/modules/ui/religions-editor.js +++ b/modules/ui/religions-editor.js @@ -120,7 +120,7 @@ function editReligions() { body.querySelectorAll("div.states").forEach(el => el.addEventListener("click", selectReligionOnLineClick)); body.querySelectorAll("rect.zoneFill").forEach(el => el.addEventListener("click", religionChangeColor)); body.querySelectorAll("div > input.religionName").forEach(el => el.addEventListener("input", religionChangeName)); - body.querySelectorAll("div > select.religionType").forEach(el => el.addEventListener("input", religionChangeType)); + body.querySelectorAll("div > select.religionType").forEach(el => el.addEventListener("change", religionChangeType)); body.querySelectorAll("div > input.religionForm").forEach(el => el.addEventListener("input", religionChangeForm)); body.querySelectorAll("div > input.religionDeity").forEach(el => el.addEventListener("input", religionChangeDeity)); body.querySelectorAll("div > span.icon-arrows-cw").forEach(el => el.addEventListener("click", regenerateDeity)); diff --git a/modules/ui/states-editor.js b/modules/ui/states-editor.js index 632f4a75..e0907b9e 100644 --- a/modules/ui/states-editor.js +++ b/modules/ui/states-editor.js @@ -53,10 +53,14 @@ function editStates() { const el = ev.target, cl = el.classList, line = el.parentNode, state = +line.dataset.id; if (cl.contains("stateCapital")) stateChangeCapitalName(state, line, el.value); else if (cl.contains("cultureType")) stateChangeType(state, line, el.value); else - if (cl.contains("stateCulture")) stateChangeCulture(state, line, el.value); else if (cl.contains("statePower")) stateChangeExpansionism(state, line, el.value); }); + body.addEventListener("change", function(ev) { + const el = ev.target, cl = el.classList, line = el.parentNode, state = +line.dataset.id; + if (cl.contains("stateCulture")) stateChangeCulture(state, line, el.value); + }); + function refreshStatesEditor() { BurgsAndStates.collectStatistics(); statesEditorAddLines();