Skip to content

Commit

Permalink
when removing the last tab, add a default new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
garbidge authored and franciscoBSalgueiro committed Oct 21, 2023
1 parent b04c11e commit 2b6c4e2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/tabs/BoardsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TreeStateProvider } from "../common/TreeStateContext";
import Puzzles from "../puzzles/Puzzles";
import { BoardTab } from "./BoardTab";
import NewTabHome from "./NewTabHome";
import { useCallback } from "react";
import { useCallback, useEffect } from "react";
import { useAtom } from "jotai";
import { activeTabAtom, tabsAtom } from "@/atoms/atoms";
import ConfirmChangesModal from "./ConfirmChangesModal";
Expand Down Expand Up @@ -45,6 +45,16 @@ export default function BoardsPage() {
const [activeTab, setActiveTab] = useAtom(activeTabAtom);
const [saveModalOpened, toggleSaveModal] = useToggle();

useEffect(() => {
if (tabs.length == 0) {
createTab({
tab: { name: "New Tab", type: "new" },
setTabs,
setActiveTab,
});
}
}, [tabs]);

const closeTab = useCallback(
async (value: string | null, forced?: boolean) => {
if (value !== null) {
Expand Down

0 comments on commit 2b6c4e2

Please sign in to comment.