Skip to content

Commit

Permalink
Make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
henhuy committed May 23, 2024
1 parent 025c4fb commit af67454
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion digiplan/static/js/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ document.querySelectorAll('.layer__switch').forEach(checkbox => {
checkbox.addEventListener('change', event => {
event.target.setAttribute('aria-checked', event.target.checked.toString());
});
});
});
14 changes: 6 additions & 8 deletions digiplan/static/js/scenarios.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ const scenarioPanels = ["panelCard1", "panelCard2", "panelCard3"];
for (const scenarioPanel of scenarioPanels) {
const panelElement = document.getElementById(scenarioPanel);
panelElement.addEventListener("click", scenarioCardClicked);
panelElement.addEventListener("keydown", function (event) {
if (event.key === "Enter" || event.key === " ") {
scenarioCardClicked(event);
}
});
panelElement.addEventListener("keydown", scenarioCardClicked);
}

Array.from(document.getElementsByClassName("scenarios__btn")).forEach(
Expand Down Expand Up @@ -80,9 +76,11 @@ function selectScenario(msg) {
}

function scenarioCardClicked(event) {
event.preventDefault(); // Prevent default action for keyboard events
const scenarioCardNumber = parseInt(event.currentTarget.id.slice(-1));
selectScenarioCard(scenarioCardNumber);
if (event.key === "Enter" || event.key === " " || event.type === "click") {
event.preventDefault(); // Prevent default action for keyboard events
const scenarioCardNumber = parseInt(event.currentTarget.id.slice(-1));
selectScenarioCard(scenarioCardNumber);
}
}

function selectScenarioCard(scenarioCardNumber) {
Expand Down

0 comments on commit af67454

Please sign in to comment.