Revert 1a7de84 except tag dropdown changes (keep apps/sim/components/ui/tag-dropdown.tsx) (#972)

This commit is contained in:
Vikhyath Mondreti
2025-08-15 02:37:16 -05:00
committed by GitHub
parent 72c07e8ad2
commit f081f5a73c
5 changed files with 30 additions and 38 deletions

View File

@@ -158,23 +158,19 @@ export function IterationBadges({ nodeId, data, iterationType }: IterationBadges
const handleEditorChange = useCallback(
(value: string) => {
if (isPreview) return
// Capture cursor first to minimize staleness in dropdown logic
const textarea = editorContainerRef.current?.querySelector(
'textarea'
) as HTMLTextAreaElement | null
const cursorPos = textarea?.selectionStart ?? cursorPosition
if (textarea) {
textareaRef.current = textarea
}
setCursorPosition(cursorPos)
collaborativeUpdateIterationCollection(nodeId, iterationType, value)
const triggerCheck = checkTagTrigger(value, cursorPos)
setShowTagDropdown(triggerCheck.show)
const textarea = editorContainerRef.current?.querySelector('textarea')
if (textarea) {
textareaRef.current = textarea
const cursorPos = textarea.selectionStart || 0
setCursorPosition(cursorPos)
const triggerCheck = checkTagTrigger(value, cursorPos)
setShowTagDropdown(triggerCheck.show)
}
},
[nodeId, iterationType, collaborativeUpdateIterationCollection, isPreview, cursorPosition]
[nodeId, iterationType, collaborativeUpdateIterationCollection, isPreview]
)
// Handle tag selection

View File

@@ -446,25 +446,24 @@ export function Code({
value={code}
onValueChange={(newCode) => {
if (!isCollapsed && !isAiStreaming && !isPreview && !disabled) {
// Capture cursor first to minimize staleness in dropdown logic
const textarea = editorRef.current?.querySelector(
'textarea'
) as HTMLTextAreaElement | null
const pos = textarea?.selectionStart ?? cursorPosition
setCursorPosition(pos)
setCode(newCode)
setStoreValue(newCode)
const tagTrigger = checkTagTrigger(newCode, pos)
setShowTags(tagTrigger.show)
if (!tagTrigger.show) {
setActiveSourceBlockId(null)
}
const textarea = editorRef.current?.querySelector('textarea')
if (textarea) {
const pos = textarea.selectionStart
setCursorPosition(pos)
const envVarTrigger = checkEnvVarTrigger(newCode, pos)
setShowEnvVars(envVarTrigger.show)
setSearchTerm(envVarTrigger.show ? envVarTrigger.searchTerm : '')
const tagTrigger = checkTagTrigger(newCode, pos)
setShowTags(tagTrigger.show)
if (!tagTrigger.show) {
setActiveSourceBlockId(null)
}
const envVarTrigger = checkEnvVarTrigger(newCode, pos)
setShowEnvVars(envVarTrigger.show)
setSearchTerm(envVarTrigger.show ? envVarTrigger.searchTerm : '')
}
}
}}
onKeyDown={(e) => {

View File

@@ -150,14 +150,13 @@ export function ComboBox({
const newValue = e.target.value
const newCursorPosition = e.target.selectionStart ?? 0
// Update cursor first to reduce staleness for dropdown logic
setCursorPosition(newCursorPosition)
// Update store value immediately (allow free text)
if (!isPreview) {
setStoreValue(newValue)
}
setCursorPosition(newCursorPosition)
// Check for environment variables trigger
const envVarTrigger = checkEnvVarTrigger(newValue, newCursorPosition)
setShowEnvVars(envVarTrigger.show)

View File

@@ -148,9 +148,6 @@ export function LongInput({
const newValue = e.target.value
const newCursorPosition = e.target.selectionStart ?? 0
// Update cursor first to minimize state staleness for dropdown selection logic
setCursorPosition(newCursorPosition)
// Update local content immediately
setLocalContent(newValue)
@@ -161,6 +158,8 @@ export function LongInput({
setStoreValue(newValue)
}
setCursorPosition(newCursorPosition)
// Check for environment variables trigger
const envVarTrigger = checkEnvVarTrigger(newValue, newCursorPosition)
setShowEnvVars(envVarTrigger.show)

View File

@@ -106,9 +106,6 @@ export function ShortInput({
const newValue = e.target.value
const newCursorPosition = e.target.selectionStart ?? 0
// Update cursor first to minimize state staleness for dropdown selection logic
setCursorPosition(newCursorPosition)
if (onChange) {
onChange(newValue)
} else if (!isPreview) {
@@ -116,6 +113,8 @@ export function ShortInput({
setStoreValue(newValue)
}
setCursorPosition(newCursorPosition)
// Check for environment variables trigger
const envVarTrigger = checkEnvVarTrigger(newValue, newCursorPosition)