From 6dc3be6029424ecb09214a4fd7a1514ff13348e8 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 15 Sep 2023 08:17:57 -0700 Subject: [PATCH] Fix: slugify tab names (#1994) --- src/components/tab.jsx | 13 ++++++++++--- src/pages/index.jsx | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/tab.jsx b/src/components/tab.jsx index ba5c52af8..bcccd9941 100644 --- a/src/components/tab.jsx +++ b/src/components/tab.jsx @@ -3,6 +3,10 @@ import classNames from "classnames"; import { TabContext } from "utils/contexts/tab"; +export function slugify(tabName) { + return tabName ? encodeURIComponent(tabName.toLowerCase()) : '' +} + export default function Tab({ tab }) { const { activeTab, setActiveTab } = useContext(TabContext); @@ -12,12 +16,15 @@ export default function Tab({ tab }) { "text-theme-700 dark:text-theme-200 relative h-8 w-full rounded-md flex m-1", )}> ); diff --git a/src/pages/index.jsx b/src/pages/index.jsx index e6d4a70dc..7e7b730f0 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -9,7 +9,7 @@ import { BiError } from "react-icons/bi"; import { serverSideTranslations } from "next-i18next/serverSideTranslations"; import { useRouter } from "next/router"; -import Tab from "components/tab"; +import Tab, { slugify } from "components/tab"; import FileContent from "components/filecontent"; import ServicesGroup from "components/services/group"; import BookmarksGroup from "components/bookmarks/group"; @@ -256,7 +256,7 @@ function Home({ initialSettings }) { }) const servicesAndBookmarksGroups = useMemo(() => { - const tabGroupFilter = g => g && [activeTab, undefined].includes(settings.layout?.[g.name]?.tab); + const tabGroupFilter = g => g && [activeTab, undefined].includes(slugify(settings.layout?.[g.name]?.tab)); const undefinedGroupFilter = g => settings.layout?.[g.name] === undefined; const layoutGroups = Object.keys(settings.layout ?? {}).map(