Fixed so that the values of the input fields are trimmed before composing the summary when they are changed.

This commit is contained in:
依瑪貓 2023-03-04 00:09:30 +08:00
parent f6ed6b10a7
commit 73f7d14e7b

View File

@ -462,6 +462,7 @@ class TagTabPlane extends TabPlane {
this.initializeTagButtons(); this.initializeTagButtons();
const tabPlane = this; const tabPlane = this;
this.tag.onchange = function () { this.tag.onchange = function () {
tabPlane.tag.value = tabPlane.tag.value.trim();
let isMatched = false; let isMatched = false;
for (const tagButton of tabPlane.tagButtons) { for (const tagButton of tabPlane.tagButtons) {
if (tagButton.dataset.value === tabPlane.tag.value) { if (tagButton.dataset.value === tabPlane.tag.value) {
@ -692,6 +693,7 @@ class GeneralTripTab extends TagTabPlane {
this.#directionButtons = Array.from(document.getElementsByClassName(this.prefix + "-direction")); this.#directionButtons = Array.from(document.getElementsByClassName(this.prefix + "-direction"));
const tabPlane = this; const tabPlane = this;
this.#from.onchange = function () { this.#from.onchange = function () {
tabPlane.#from.value = tabPlane.#from.value.trim();
tabPlane.updateSummary(); tabPlane.updateSummary();
tabPlane.validateFrom(); tabPlane.validateFrom();
}; };
@ -707,6 +709,7 @@ class GeneralTripTab extends TagTabPlane {
}; };
} }
this.#to.onchange = function () { this.#to.onchange = function () {
tabPlane.#to.value = tabPlane.#to.value.trim();
tabPlane.updateSummary(); tabPlane.updateSummary();
tabPlane.validateTo(); tabPlane.validateTo();
}; };
@ -900,14 +903,17 @@ class BusTripTab extends TagTabPlane {
this.#toError = document.getElementById(this.prefix + "-to-error") this.#toError = document.getElementById(this.prefix + "-to-error")
const tabPlane = this; const tabPlane = this;
this.#route.onchange = function () { this.#route.onchange = function () {
tabPlane.#route.value = tabPlane.#route.value.trim();
tabPlane.updateSummary(); tabPlane.updateSummary();
tabPlane.validateRoute(); tabPlane.validateRoute();
}; };
this.#from.onchange = function () { this.#from.onchange = function () {
tabPlane.#from.value = tabPlane.#from.value.trim();
tabPlane.updateSummary(); tabPlane.updateSummary();
tabPlane.validateFrom(); tabPlane.validateFrom();
}; };
this.#to.onchange = function () { this.#to.onchange = function () {
tabPlane.#to.value = tabPlane.#to.value.trim();
tabPlane.updateSummary(); tabPlane.updateSummary();
tabPlane.validateTo(); tabPlane.validateTo();
}; };