Auto-focus input after adding new row

This commit is contained in:
Florine W. Dekker 2021-11-14 11:14:16 +01:00
parent e4862b60ad
commit b04d4b12df
Signed by: FWDekker
GPG Key ID: D3DCFAA8A4560BE0
3 changed files with 11 additions and 20 deletions

BIN
package-lock.json generated

Binary file not shown.

View File

@ -1,6 +1,6 @@
{ {
"name": "dice", "name": "dice",
"version": "1.0.15", "version": "1.0.16",
"description": "Calculates the probability of rolling a value given a combination of dice.", "description": "Calculates the probability of rolling a value given a combination of dice.",
"author": "F.W. Dekker", "author": "F.W. Dekker",
"browser": "dist/bundle.js", "browser": "dist/bundle.js",
@ -16,18 +16,18 @@
"deploy": "grunt deploy" "deploy": "grunt deploy"
}, },
"dependencies": { "dependencies": {
"chart.js": "^3.2.0" "chart.js": "^3.6.0"
}, },
"devDependencies": { "devDependencies": {
"grunt": "^1.4.0", "grunt": "^1.4.1",
"grunt-cli": "^1.4.2", "grunt-cli": "^1.4.3",
"grunt-contrib-clean": "^2.0.0", "grunt-contrib-clean": "^2.0.0",
"grunt-contrib-copy": "^1.0.0", "grunt-contrib-copy": "^1.0.0",
"grunt-contrib-watch": "^1.1.0", "grunt-contrib-watch": "^1.1.0",
"grunt-focus": "^1.0.0", "grunt-focus": "^1.0.0",
"grunt-text-replace": "^0.4.0", "grunt-text-replace": "^0.4.0",
"grunt-webpack": "^4.0.3", "grunt-webpack": "^5.0.0",
"webpack": "^5.36.0", "webpack": "^5.64.0",
"webpack-cli": "^4.6.0" "webpack-cli": "^4.9.1"
} }
} }

View File

@ -98,7 +98,6 @@ inputTable.addDieRow = () => {
if (e.key === "Enter") if (e.key === "Enter")
outputChart.updateProbGraph(); outputChart.updateProbGraph();
}); });
input.focus();
return input; return input;
}; };
@ -122,6 +121,8 @@ inputTable.addDieRow = () => {
row.insertCell().appendChild(createNumberInput(newIndex, "dieEyes", 6)); row.insertCell().appendChild(createNumberInput(newIndex, "dieEyes", 6));
row.insertCell().appendChild(createNumberInput(newIndex, "dieCount", 2)); row.insertCell().appendChild(createNumberInput(newIndex, "dieCount", 2));
row.insertCell().appendChild(createRemoveLink(newIndex, "dieRemove")); row.insertCell().appendChild(createRemoveLink(newIndex, "dieRemove"));
$("#dieEyes" + newIndex).focus();
}; };
inputTable.removeDieRow = index => { inputTable.removeDieRow = index => {
@ -152,7 +153,7 @@ inputTable.getDice = () => {
doAfterLoad(() => { doAfterLoad(() => {
const button = $("#addDieRowButton"); const button = $("#addDieRowButton");
button.onclick = inputTable.addDieRow; button.onclick = inputTable.addDieRow;
button.click() button.click();
}); });
@ -215,17 +216,7 @@ doAfterLoad(() => {
probChart = new Chart($("#probChart").getContext("2d"), { probChart = new Chart($("#probChart").getContext("2d"), {
type: "line", type: "line",
data: {}, data: {},
options: { options: {fill: true},
fill: true,
scales: {
yAxes: [{
display: true,
ticks: {
suggestedMin: 0
}
}]
}
}
}); });
const submit = $("#submit"); const submit = $("#submit");