Skip to content

Commit e0d1ee4

Browse files
authored
fix(settings): fix dropdown not rendered correctly (@fehmer) (monkeytypegame#6468)
Dropdowns for layoutfluid and polyglot were not rendered correctly after logout/login
1 parent a9c2f52 commit e0d1ee4

File tree

2 files changed

+27
-38
lines changed

2 files changed

+27
-38
lines changed

frontend/src/ts/commandline/lists.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ export const commands: CommandsSubgroup = {
219219
id: "changeCustomLayoutfluid",
220220
display: "Custom layoutfluid...",
221221
defaultValue: (): string => {
222-
return Config.customLayoutfluid;
222+
return Config.customLayoutfluid.replace(/#/g, " ");
223223
},
224224
input: true,
225225
icon: "fa-tint",
226226
exec: ({ input }): void => {
227227
if (input === undefined) return;
228-
UpdateConfig.setCustomLayoutfluid(input);
228+
UpdateConfig.setCustomLayoutfluid(input.replace(/ /g, "#"));
229229
},
230230
},
231231
{

frontend/src/ts/pages/settings.ts

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -679,45 +679,34 @@ async function fillSettingsPage(): Promise<void> {
679679
Config.keymapSize
680680
);
681681

682-
if (customLayoutFluidSelect === undefined) {
683-
const customLayoutfluidElement = document.querySelector(
684-
".pageSettings .section[data-config-name='customLayoutfluid'] select"
685-
) as Element;
686-
687-
customLayoutFluidSelect = new SlimSelect({
688-
select: customLayoutfluidElement,
689-
settings: { keepOrder: true },
690-
events: {
691-
afterChange: (newVal): void => {
692-
const customLayoutfluid = newVal.map((it) => it.value).join("#");
693-
if (customLayoutfluid !== Config.customLayoutfluid) {
694-
void UpdateConfig.setCustomLayoutfluid(customLayoutfluid);
695-
}
696-
},
682+
customLayoutFluidSelect = new SlimSelect({
683+
select:
684+
".pageSettings .section[data-config-name='customLayoutfluid'] select",
685+
settings: { keepOrder: true },
686+
events: {
687+
afterChange: (newVal): void => {
688+
const customLayoutfluid = newVal.map((it) => it.value).join("#");
689+
if (customLayoutfluid !== Config.customLayoutfluid) {
690+
void UpdateConfig.setCustomLayoutfluid(customLayoutfluid);
691+
}
697692
},
698-
});
699-
}
693+
},
694+
});
700695

701-
if (customPolyglotSelect === undefined) {
702-
const customPolyglotElement = document.querySelector(
703-
".pageSettings .section[data-config-name='customPolyglot'] select"
704-
) as Element;
705-
706-
customPolyglotSelect = new SlimSelect({
707-
select: customPolyglotElement,
708-
data: getLanguageDropdownData(languageGroups ?? [], (language) =>
709-
Config.customPolyglot.includes(language)
710-
),
711-
events: {
712-
afterChange: (newVal): void => {
713-
const customPolyglot = newVal.map((it) => it.value);
714-
if (customPolyglot.toSorted() !== Config.customPolyglot.toSorted()) {
715-
void UpdateConfig.setCustomPolyglot(customPolyglot);
716-
}
717-
},
696+
customPolyglotSelect = new SlimSelect({
697+
select: ".pageSettings .section[data-config-name='customPolyglot'] select",
698+
data: getLanguageDropdownData(languageGroups ?? [], (language) =>
699+
Config.customPolyglot.includes(language)
700+
),
701+
events: {
702+
afterChange: (newVal): void => {
703+
const customPolyglot = newVal.map((it) => it.value);
704+
if (customPolyglot.toSorted() !== Config.customPolyglot.toSorted()) {
705+
void UpdateConfig.setCustomPolyglot(customPolyglot);
706+
}
718707
},
719-
});
720-
}
708+
},
709+
});
721710

722711
$(".pageSettings .section[data-config-name='tapeMargin'] input").val(
723712
Config.tapeMargin

0 commit comments

Comments
 (0)