Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
fix: Hide active sidebar tab when switching to preview mode (#3142)
Oleg Isonen690e541e1463
diff --git a/apps/builder/app/builder/features/sidebar-left/sidebar-left.tsx b/apps/builder/app/builder/features/sidebar-left/sidebar-left.tsxindex ce39ab8d46..5ffc12950d 100644--- a/apps/builder/app/builder/features/sidebar-left/sidebar-left.tsx+++ b/apps/builder/app/builder/features/sidebar-left/sidebar-left.tsx@@ -1,4 +1,4 @@-import { useState } from "react";+import { useEffect, useState } from "react";import { Box, Tooltip, rawTheme } from "@webstudio-is/design-system";import { useSubscribe, type Publish } from "~/shared/pubsub";import { $dragAndDropState, $isPreviewMode } from "~/shared/nano-states";@@ -32,6 +32,17 @@ const useActiveTab = () => {return [nextTab, $activeSidebarPanel.set] as const;};+const useHideActiveTabOnPreview = () => {+ useEffect(() => {+ return $isPreviewMode.subscribe((isPreviewMode) => {+ // When user switches to preview mode we want to hide any active sidebar panel.+ if (isPreviewMode) {+ $activeSidebarPanel.set("none");+ }+ });+ }, []);+};+const AiTabTrigger = () => {const [clientSettings, setClientSetting] = useClientSettings();return (@@ -97,6 +108,7 @@ type SidebarLeftProps = {export const SidebarLeft = ({ publish }: SidebarLeftProps) => {const [activeTab, setActiveTab] = useActiveTab();+ useHideActiveTabOnPreview();const dragAndDropState = useStore($dragAndDropState);const { TabContent } = panels.get(activeTab) ?? none;const isPreviewMode = useStore($isPreviewMode);