web: only auto-update slug when slug and name are already in sync
This commit is contained in:
parent
434922f702
commit
1524061480
|
@ -64,7 +64,6 @@ export class ModalButton extends LitElement {
|
||||||
});
|
});
|
||||||
// Make name field update slug field
|
// Make name field update slug field
|
||||||
this.querySelectorAll<HTMLInputElement>("input[name=name]").forEach((input) => {
|
this.querySelectorAll<HTMLInputElement>("input[name=name]").forEach((input) => {
|
||||||
input.addEventListener("input", () => {
|
|
||||||
const form = input.closest("form");
|
const form = input.closest("form");
|
||||||
if (form === null) {
|
if (form === null) {
|
||||||
return;
|
return;
|
||||||
|
@ -73,6 +72,13 @@ export class ModalButton extends LitElement {
|
||||||
if (!slugField) {
|
if (!slugField) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Only attach handler if the slug is already equal to the name
|
||||||
|
// if not, they are probably completely different and shouldn't update
|
||||||
|
// each other
|
||||||
|
if (convertToSlug(input.value) !== slugField.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
input.addEventListener("input", () => {
|
||||||
slugField.value = convertToSlug(input.value);
|
slugField.value = convertToSlug(input.value);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Reference in New Issue