Skip to content

Commit 0c1e1f2

Browse files
authored
fix(settings): remove highlight if not set (@fehmer) (monkeytypegame#6711)
1. config highlight was shown again if you - select a deep link - go to another page - go to the settings page 2. when closing a settings group with a highlight the animation broke 3. when opening a closed settings group with a highlight the animation was repeated
1 parent f130947 commit 0c1e1f2

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

frontend/src/ts/pages/settings.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,9 @@ export async function update(): Promise<void> {
869869
}
870870
}
871871
function toggleSettingsGroup(groupName: string): void {
872+
//The highlight is repeated/broken when toggling the group
873+
handleHighlightSection(undefined);
874+
872875
const groupEl = $(`.pageSettings .settingsGroup.${groupName}`);
873876
groupEl.stop(true, true).slideToggle(250).toggleClass("slideup");
874877
if (groupEl.hasClass("slideup")) {
@@ -1353,7 +1356,15 @@ function getThemeDropdownData(
13531356
}));
13541357
}
13551358

1356-
function handleHighlightSection(highlight: Highlight): void {
1359+
function handleHighlightSection(highlight: Highlight | undefined): void {
1360+
if (highlight === undefined) {
1361+
const element = document.querySelector(".section.highlight");
1362+
if (element !== null) {
1363+
element.classList.remove("highlight");
1364+
}
1365+
return;
1366+
}
1367+
13571368
const element = document.querySelector(
13581369
`[data-config-name="${highlight}"] .groupTitle,[data-section-id="${highlight}"] .groupTitle`
13591370
);
@@ -1419,9 +1430,8 @@ export const page = new PageWithUrlParams({
14191430
await UpdateConfig.loadPromise;
14201431
await fillSettingsPage();
14211432
await update();
1422-
if (options.urlParams?.highlight !== undefined) {
1423-
handleHighlightSection(options.urlParams.highlight);
1424-
}
1433+
1434+
handleHighlightSection(options.urlParams?.highlight);
14251435
},
14261436
});
14271437

0 commit comments

Comments
 (0)