mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-09-06 06:37:35 +08:00
fix(settings): fix dropdown not rendered correctly (@fehmer) (#6468)
Dropdowns for layoutfluid and polyglot were not rendered correctly after logout/login
This commit is contained in:
parent
a9c2f52dde
commit
e0d1ee4cf7
2 changed files with 27 additions and 38 deletions
|
@ -219,13 +219,13 @@ export const commands: CommandsSubgroup = {
|
|||
id: "changeCustomLayoutfluid",
|
||||
display: "Custom layoutfluid...",
|
||||
defaultValue: (): string => {
|
||||
return Config.customLayoutfluid;
|
||||
return Config.customLayoutfluid.replace(/#/g, " ");
|
||||
},
|
||||
input: true,
|
||||
icon: "fa-tint",
|
||||
exec: ({ input }): void => {
|
||||
if (input === undefined) return;
|
||||
UpdateConfig.setCustomLayoutfluid(input);
|
||||
UpdateConfig.setCustomLayoutfluid(input.replace(/ /g, "#"));
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -679,45 +679,34 @@ async function fillSettingsPage(): Promise<void> {
|
|||
Config.keymapSize
|
||||
);
|
||||
|
||||
if (customLayoutFluidSelect === undefined) {
|
||||
const customLayoutfluidElement = document.querySelector(
|
||||
".pageSettings .section[data-config-name='customLayoutfluid'] select"
|
||||
) as Element;
|
||||
|
||||
customLayoutFluidSelect = new SlimSelect({
|
||||
select: customLayoutfluidElement,
|
||||
settings: { keepOrder: true },
|
||||
events: {
|
||||
afterChange: (newVal): void => {
|
||||
const customLayoutfluid = newVal.map((it) => it.value).join("#");
|
||||
if (customLayoutfluid !== Config.customLayoutfluid) {
|
||||
void UpdateConfig.setCustomLayoutfluid(customLayoutfluid);
|
||||
}
|
||||
},
|
||||
customLayoutFluidSelect = new SlimSelect({
|
||||
select:
|
||||
".pageSettings .section[data-config-name='customLayoutfluid'] select",
|
||||
settings: { keepOrder: true },
|
||||
events: {
|
||||
afterChange: (newVal): void => {
|
||||
const customLayoutfluid = newVal.map((it) => it.value).join("#");
|
||||
if (customLayoutfluid !== Config.customLayoutfluid) {
|
||||
void UpdateConfig.setCustomLayoutfluid(customLayoutfluid);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
if (customPolyglotSelect === undefined) {
|
||||
const customPolyglotElement = document.querySelector(
|
||||
".pageSettings .section[data-config-name='customPolyglot'] select"
|
||||
) as Element;
|
||||
|
||||
customPolyglotSelect = new SlimSelect({
|
||||
select: customPolyglotElement,
|
||||
data: getLanguageDropdownData(languageGroups ?? [], (language) =>
|
||||
Config.customPolyglot.includes(language)
|
||||
),
|
||||
events: {
|
||||
afterChange: (newVal): void => {
|
||||
const customPolyglot = newVal.map((it) => it.value);
|
||||
if (customPolyglot.toSorted() !== Config.customPolyglot.toSorted()) {
|
||||
void UpdateConfig.setCustomPolyglot(customPolyglot);
|
||||
}
|
||||
},
|
||||
customPolyglotSelect = new SlimSelect({
|
||||
select: ".pageSettings .section[data-config-name='customPolyglot'] select",
|
||||
data: getLanguageDropdownData(languageGroups ?? [], (language) =>
|
||||
Config.customPolyglot.includes(language)
|
||||
),
|
||||
events: {
|
||||
afterChange: (newVal): void => {
|
||||
const customPolyglot = newVal.map((it) => it.value);
|
||||
if (customPolyglot.toSorted() !== Config.customPolyglot.toSorted()) {
|
||||
void UpdateConfig.setCustomPolyglot(customPolyglot);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
$(".pageSettings .section[data-config-name='tapeMargin'] input").val(
|
||||
Config.tapeMargin
|
||||
|
|
Loading…
Add table
Reference in a new issue