Skip to content

Conversation

@emir-karabeg
Copy link
Collaborator

Summary

Fixes a bug where creating a new folder or workflow inside a collapsed parent folder would not automatically expand the parent, making the newly created item invisible and preventing the scroll-to-item functionality from working. This ensures a clear user experience by automatically revealing new items.

Fixes #(issue) - [Bug] When I create a folder inside of another folder, it doesn't open that folder and scroll.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

The fix was verified by running lint and type checks, which passed. The behavior was manually tested by creating new folders and workflows within collapsed parent folders to confirm they now expand and scroll correctly.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos


Open in Cursor Open in Web

Co-authored-by: emir <emir@simstudio.ai>
@cursor
Copy link

cursor bot commented Dec 23, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@vercel
Copy link

vercel bot commented Dec 23, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Dec 23, 2025 11:38pm

@waleedlatif1 waleedlatif1 changed the title Folder creation scroll behavior fix(folders): folder creation scroll behavior Dec 23, 2025
@waleedlatif1 waleedlatif1 marked this pull request as ready for review December 23, 2025 23:49
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 23, 2025

Greptile Summary

This PR fixes a UX bug where newly created folders or workflows inside a collapsed parent folder were invisible because the parent wasn't automatically expanded.

  • Added expandFolder function to the useFolderExpand hook that explicitly expands a folder (vs toggling)
  • Integrated expandFolder() calls in both handleCreateWorkflowInFolder and handleCreateFolderInFolder callbacks
  • Moved the hook declaration before the callbacks that depend on it to maintain proper React hook ordering
  • Updated dependency arrays to include the new expandFolder function

The fix ensures that when a user creates a new item inside a folder, the parent folder expands automatically before the scroll-to-item event fires, making the new item visible.

Confidence Score: 5/5

  • This PR is safe to merge - simple, focused bug fix with minimal risk
  • The changes are minimal, well-structured, and follow existing patterns. The new expandFolder function uses an existing store method (setExpanded), hook dependencies are correctly updated, and the fix directly addresses the reported bug without side effects.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-folder-expand.ts Added expandFolder function to explicitly expand a folder when items are created inside it, properly wrapped in useCallback with correct dependencies.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/folder-item/folder-item.tsx Moved hook declaration before callbacks using it, added expandFolder calls after workflow/folder creation to ensure visibility, dependency arrays correctly updated.

Sequence Diagram

sequenceDiagram
    participant User
    participant FolderItem
    participant CreateMutation
    participant useFolderExpand
    participant FolderStore
    participant Sidebar

    User->>FolderItem: Create workflow/folder in collapsed folder
    FolderItem->>CreateMutation: mutateAsync()
    CreateMutation-->>FolderItem: result with new item id
    FolderItem->>useFolderExpand: expandFolder()
    useFolderExpand->>FolderStore: setExpanded(folderId, true)
    FolderStore-->>useFolderExpand: Folder expanded
    FolderItem->>Sidebar: dispatch SIDEBAR_SCROLL_EVENT
    Sidebar-->>User: New item visible and scrolled into view
Loading

@waleedlatif1 waleedlatif1 merged commit 31de55c into staging Dec 24, 2025
11 checks passed
@waleedlatif1 waleedlatif1 deleted the cursor/folder-creation-scroll-behavior-c067 branch December 24, 2025 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants