Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • fix envvar dropdown positioning, remove dead code

Type of Change

  • Bug fix

Testing

Tested manually

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)

@vercel
Copy link

vercel bot commented Dec 4, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Dec 4, 2025 10:33pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 4, 2025

Greptile Overview

Greptile Summary

Fixed environment variable dropdown positioning behavior in API key fields and removed unused code.

  • Prevented dropdown from appearing when pasting long API keys by tracking paste events with justPastedRef
  • Prevented dropdown from showing on focus when field contains long values (>20 chars) without variable syntax
  • Added heuristic to detect raw API keys during typing (>30 chars, no {{, no env var pattern) and suppress dropdown
  • Removed dead code: scrollToCursor function, inputRef, auto-scroll effect, and unused memoized values
  • Removed redundant comment blocks

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are focused on fixing a specific UX issue with dropdown positioning and removing demonstrably unused code. The logic is straightforward, adds appropriate safeguards, and doesn't modify core functionality. No security concerns, type safety maintained, and the changes align with the stated bug fix purpose.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/short-input/short-input.tsx 5/5 Removed dead code (scrollToCursor function, inputRef, auto-scroll effect) and improved envvar dropdown positioning logic by preventing it from appearing when pasting or when long API keys are already present

Sequence Diagram

sequenceDiagram
    participant User
    participant ShortInput
    participant SubBlockInputController
    participant EnvVarDropdown
    
    alt User pastes API key
        User->>ShortInput: onPaste event
        ShortInput->>ShortInput: Set justPastedRef.current = true
        ShortInput->>ShortInput: Schedule reset (100ms timeout)
        User->>ShortInput: onChange triggered
        ShortInput->>ShortInput: shouldForceEnvDropdown({ event: 'change' })
        ShortInput->>ShortInput: Check justPastedRef.current === true
        ShortInput->>SubBlockInputController: Return { show: false }
        Note over EnvVarDropdown: Dropdown NOT shown (fixed behavior)
        ShortInput->>ShortInput: Reset justPastedRef.current = false
    end
    
    alt User focuses on field with long API key
        User->>ShortInput: onFocus event
        ShortInput->>ShortInput: shouldForceEnvDropdown({ event: 'focus' })
        ShortInput->>ShortInput: Check value.length > 20 && !value.includes('{{')
        ShortInput->>SubBlockInputController: Return { show: false }
        Note over EnvVarDropdown: Dropdown NOT shown (fixed behavior)
    end
    
    alt User types in API key field
        User->>ShortInput: onChange event
        ShortInput->>ShortInput: shouldForceEnvDropdown({ event: 'change' })
        ShortInput->>ShortInput: Check if looksLikeRawApiKey
        alt Looks like raw API key (length > 30, no '{{', no env var pattern)
            ShortInput->>SubBlockInputController: Return { show: false }
            Note over EnvVarDropdown: Dropdown NOT shown
        else Looks like env var reference
            ShortInput->>SubBlockInputController: Return { show: true, searchTerm: value }
            SubBlockInputController->>EnvVarDropdown: Show dropdown with search
            EnvVarDropdown-->>User: Display filtered env vars
        end
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit dc5a2b1 into staging Dec 4, 2025
5 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/short-inp branch December 4, 2025 22:35
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.

2 participants