Skip to content

Commit

Permalink
update title in games selection
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoBSalgueiro committed Mar 14, 2024
1 parent 1523336 commit e17845b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/components/common/GameInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import { TreeDispatchContext } from "./TreeStateContext";
function GameInfo({
headers,
simplified,
changeTitle,
}: {
headers: GameHeaders;
simplified?: boolean;
changeTitle?: (title: string) => void;
}) {
const dispatch = useContext(TreeDispatchContext);
const disabled = dispatch.length === 0;
Expand Down Expand Up @@ -74,6 +76,9 @@ function GameInfo({
event: e.target.value,
},
});
if (changeTitle) {
changeTitle(e.target.value);
}
}}
/>
{headers.round && headers.round !== "?" && (
Expand Down
12 changes: 11 additions & 1 deletion src/components/panels/info/InfoPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ function InfoPanel() {
<ScrollArea offsetScrollbars>
<FileInfo setGames={setGames} />
<Stack>
<GameInfo headers={tree.headers} simplified={isReportoire} />
<GameInfo
headers={tree.headers}
simplified={isReportoire}
changeTitle={(title: string) => {
setGames((prev) => {
const newGames = new Map(prev);
newGames.set(currentTab?.gameNumber || 0, title);
return newGames;
});
}}
/>
<FenSearch currentFen={currentNode.fen} />
<PgnInput />

Expand Down

0 comments on commit e17845b

Please sign in to comment.