Skip to content

Commit 632d436

Browse files
committed
fix(settings): not reseting ui state on cancel changes
1 parent b328a04 commit 632d436

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/ui/react/settings/components/navigation/index.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Icon } from "libs/ui/react/components/Icon/index.tsx";
22
import { ResourceText } from "libs/ui/react/components/ResourceText/index.tsx";
3+
import { getResourceText } from "libs/ui/react/utils/index.ts";
34
import { Tooltip } from "antd";
45
import { memo, useState } from "react";
56
import { useTranslation } from "react-i18next";
@@ -17,7 +18,7 @@ export const Navigation = memo(() => {
1718
const activeThemes = settings.value.activeThemes;
1819
const devTools = settings.value.devTools;
1920

20-
const { t } = useTranslation();
21+
const { t, i18n } = useTranslation();
2122
const location = useLocation();
2223

2324
const Mapper = (route: RoutePath | null) => {
@@ -81,7 +82,11 @@ export const Navigation = memo(() => {
8182
<div className={cs.group}>
8283
{widgets.value
8384
.filter((widget) => !widget.hidden)
84-
.toSorted((a, b) => a.id.localeCompare(b.id))
85+
.toSorted((a, b) => {
86+
const aName = getResourceText(a.metadata.displayName, i18n.language);
87+
const bName = getResourceText(b.metadata.displayName, i18n.language);
88+
return aName.localeCompare(bName, i18n.language);
89+
})
8590
.map((widget) => (
8691
<Item
8792
key={widget.id}
@@ -99,7 +104,11 @@ export const Navigation = memo(() => {
99104
<div className={cs.separator} />
100105
<div className={cs.group}>
101106
{themesDirectAccess
102-
.toSorted((a, b) => a.id.localeCompare(b.id))
107+
.toSorted((a, b) => {
108+
const aName = getResourceText(a.metadata.displayName, i18n.language);
109+
const bName = getResourceText(b.metadata.displayName, i18n.language);
110+
return aName.localeCompare(bName, i18n.language);
111+
})
103112
.map((theme) => (
104113
<Item
105114
key={theme.id}

src/ui/react/settings/modules/resources/Widget/ConfigRenderer.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ function renderInput(
130130
onConfigChange: (key: string, value: any) => void,
131131
): ReactNode {
132132
const commonProps = {
133-
defaultValue: def.defaultValue as any,
134-
value: values[def.key],
133+
value: values[def.key] ?? def.defaultValue,
135134
onChange: (value: any) => onConfigChange(def.key, value),
136135
};
137136

0 commit comments

Comments
 (0)