Skip to content

Commit e930d0c

Browse files
committed
fix: unable to delete a preset in some cases
closes monkeytypegame#7068 closes monkeytypegame#7064
1 parent ffd55c5 commit e930d0c

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

frontend/src/ts/modals/edit-preset.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,17 +254,21 @@ async function apply(): Promise<void> {
254254
return;
255255
}
256256

257-
const noPresetName: boolean =
258-
["add", "edit"].includes(action) &&
259-
presetName.replace(/^_+|_+$/g, "").length === 0; //all whitespace names are rejected
260-
if (noPresetName) {
261-
Notifications.add("Preset name cannot be empty", 0);
262-
return;
263-
}
257+
const addOrEditAction = action === "add" || action === "edit";
258+
if (addOrEditAction) {
259+
//validate the preset name only in add or edit mode
260+
261+
const noPresetName: boolean =
262+
presetName.replace(/^_+|_+$/g, "").length === 0; //all whitespace names are rejected
263+
if (noPresetName) {
264+
Notifications.add("Preset name cannot be empty", 0);
265+
return;
266+
}
264267

265-
if (presetNameEl?.getValidationResult().status === "failed") {
266-
Notifications.add("Preset name is not valid", 0);
267-
return;
268+
if (presetNameEl?.getValidationResult().status === "failed") {
269+
Notifications.add("Preset name is not valid", 0);
270+
return;
271+
}
268272
}
269273

270274
hide();

0 commit comments

Comments
 (0)