diff --git a/src/plugins/holynotes/components/modals/NoteBookTab.tsx b/src/plugins/holynotes/components/modals/NoteBookTab.tsx index ab917fc00..8c1e1c7f5 100644 --- a/src/plugins/holynotes/components/modals/NoteBookTab.tsx +++ b/src/plugins/holynotes/components/modals/NoteBookTab.tsx @@ -6,18 +6,18 @@ import { classes } from "@utils/misc"; import { findByProps } from "@webpack"; -import { Button, Clickable, Menu, Popout, React, TabBar } from "@webpack/common"; +import { Button, Clickable, Menu, Popout, React } from "@webpack/common"; import { SvgOverFlowIcon } from "../icons/overFlowIcon"; -export function NoteBookTabs({ tabs, selectedTabId, onSelectTab }) { +export function NoteBookTabs({ tabs, selectedTabId, onSelectTab }: { tabs: string[], selectedTabId: string, onSelectTab: (tab: string) => void }) { const tabBarRef = React.useRef(null); const widthRef = React.useRef(0); const tabWidthMapRef = React.useRef(new Map()); - const [overflowedTabs, setOverflowedTabs] = React.useState([]); - const resizeObserverRef = React.useRef(null); + const [overflowedTabs, setOverflowedTabs] = React.useState([]); + const resizeObserverRef = React.useRef(null); const [show, setShow] = React.useState(false); const { isNotNullish } = findByProps("isNotNullish"); @@ -25,7 +25,7 @@ export function NoteBookTabs({ tabs, selectedTabId, onSelectTab }) { const handleResize = React.useCallback(() => { if (!tabBarRef.current) return; - const overflowed = []; + const overflowed = [] as string[]; const totalWidth = tabBarRef.current.clientWidth; if (totalWidth !== widthRef.current) { @@ -61,11 +61,12 @@ export function NoteBookTabs({ tabs, selectedTabId, onSelectTab }) { }; }, [handleResize]); - const TabItem = React.forwardRef(function ({ id, selected, onClick, children }, ref) { + const TabItem = React.forwardRef(function ({ id, selected, onClick, children }: { id: string, selected: boolean, onClick: () => void, children: React.ReactNode }, ref) { return ( @@ -109,14 +110,14 @@ export function NoteBookTabs({ tabs, selectedTabId, onSelectTab }) { { + ref={(el: HTMLElement | null) => { const width = tabWidthMapRef.current.get(tab)?.width ?? 0; tabWidthMapRef.current.set(tab, { node: el, width: el ? el.getBoundingClientRect().width : width }); }} - onClick={selectedTabId !== tab ? () => onSelectTab(tab) : undefined} + onClick={selectedTabId !== tab ? () => onSelectTab(tab) : () => {}} > {tab} @@ -177,7 +178,7 @@ export function CreateTabBar({ tabs, firstSelectedTab, onChangeTab }) { TabBar: { + onSelectTab={tab => { setSelectedTab(tab); if (onChangeTab) onChangeTab(tab); }} />,