diff --git a/frontend/src/ts/modals/edit-tag.ts b/frontend/src/ts/modals/edit-tag.ts index e01bcde89..d400c2b5a 100644 --- a/frontend/src/ts/modals/edit-tag.ts +++ b/frontend/src/ts/modals/edit-tag.ts @@ -151,17 +151,19 @@ const actionModals: Record = { }; } - DB.getSnapshot()?.tags?.forEach((tag) => { - if (tag._id === tagId) { - tag.personalBests = { - time: {}, - words: {}, - quote: {}, - zen: {}, - custom: {}, - }; - } - }); + const matchingTag = DB.getSnapshot()?.tags.find( + (tag) => tag._id === tagId, + ); + + if (matchingTag !== undefined) { + matchingTag.personalBests = { + time: {}, + words: {}, + quote: {}, + zen: {}, + custom: {}, + }; + } void Settings.update(); return { status: 1, message: `Tag PB cleared` };