Skip to content

Commit 011aa55

Browse files
authored
Fix Sidebar Button being left behind when collapsed (#1441)
## Description <!-- Please provide a brief description of the changes made in this pull request. Include any relevant context or reasoning for the changes. --> Fix a bug where closing the sidebar then navigating to another pipeline results in the sidebar icon being detached from the sidebar. Side note: The `Sidebar` component and associated provider etc needs cleaning up. Are we actually intending to use this or do our own custom thing? ## Related Issue and Pull requests <!-- Link to any related issues using the format #<issue-number> --> Closes Shopify/oasis-frontend#365 ## Type of Change <!-- Please delete options that are not relevant --> - [x] Bug fix ## Checklist <!-- Please ensure the following are completed before submitting the PR --> - [ ] I have tested this does not break current pipelines / runs functionality - [ ] I have tested the changes on staging ## Screenshots (if applicable) <!-- Include any screenshots that might help explain the changes or provide visual context --> ## Test Instructions <!-- Detail steps and prerequisites for testing the changes in this PR --> ## Additional Comments <!-- Add any additional context or information that reviewers might need to know regarding this PR -->
1 parent a5db934 commit 011aa55

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/components/shared/ReactFlow/FlowSidebar/FlowSidebar.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { useState } from "react";
2-
31
import {
42
Sidebar,
53
SidebarContent,
64
SidebarTrigger,
5+
useSidebar,
76
} from "@/components/ui/sidebar";
87
import { cn } from "@/lib/utils";
98

@@ -12,19 +11,19 @@ import GraphComponents from "./sections/GraphComponents";
1211
import RunsAndSubmission from "./sections/RunsAndSubmission";
1312

1413
const FlowSidebar = () => {
15-
const [isOpen, setIsOpen] = useState(true);
14+
const { open, setOpen } = useSidebar();
1615

1716
const sidebarTriggerClasses = cn(
1817
"absolute top-[65px] z-1 transition-all duration-300 bg-white mt-8 rounded-r-md shadow-md p-0.5 pr-1",
19-
isOpen ? "left-[255px]" : "left-[47px]",
18+
open ? "left-[255px]" : "left-[47px]",
2019
);
2120

2221
return (
2322
<>
2423
<div className={sidebarTriggerClasses}>
2524
<SidebarTrigger
2625
className="text-gray-600 hover:bg-gray-50 hover:text-gray-900"
27-
onClick={() => setIsOpen(!isOpen)}
26+
onClick={() => setOpen(!open)}
2827
/>
2928
</div>
3029
<Sidebar
@@ -33,9 +32,9 @@ const FlowSidebar = () => {
3332
collapsible="icon"
3433
>
3534
<SidebarContent className="gap-0! m-0! p-0!">
36-
<FileActions isOpen={isOpen} />
37-
<RunsAndSubmission isOpen={isOpen} />
38-
<GraphComponents isOpen={isOpen} />
35+
<FileActions isOpen={open} />
36+
<RunsAndSubmission isOpen={open} />
37+
<GraphComponents isOpen={open} />
3938
</SidebarContent>
4039
</Sidebar>
4140
</>

0 commit comments

Comments
 (0)