fix: ConfigTemplate infinite re-render loop and add E2E test

This commit is contained in:
sokol
2026-02-18 17:25:50 +03:00
parent 15f890abda
commit 5890745ed2
3 changed files with 61 additions and 11 deletions

View File

@@ -12,7 +12,7 @@ export function Content(props: { config: Config, env: Env, onTemplateSaved: (new
return (
<>
<ContentTabs onSelected={(id) => setTab(id)} />
<ContentTabs onSelected={(id) => setTab(id)} selectedTab={selectTab} />
<div className="">
{selectTab == ContentType.Env ? (<ContentParams env={props.env} />) : ""}
{selectTab == ContentType.Json ? (<ConfigTemplate config={props.config} onSaved={props.onTemplateSaved} />) : ""}
@@ -30,16 +30,13 @@ enum ContentType {
Test = 3
}
function ContentTabs(props: { onSelected: (id: ContentType) => void }) {
const [selectTab, setSelect] = useState(ContentType.Env);
function ContentTabs(props: { onSelected: (id: ContentType) => void, selectedTab: ContentType }) {
function clickHandler(type: ContentType) {
setSelect(type);
props.onSelected(type);
}
function isActive(type: ContentType): string {
return type == selectTab ? " active" : " ";
return type == props.selectedTab ? " active" : " ";
}
return (