Skip to content

Commit 27c7bcf

Browse files
committed
Add tag dropdowns
1 parent 0bc8c0e commit 27c7bcf

File tree

1 file changed

+98
-17
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/condition-input

1 file changed

+98
-17
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/condition-input/condition-input.tsx

Lines changed: 98 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -830,25 +830,106 @@ export function ConditionInput({
830830
</Tooltip.Root>
831831
</div>
832832
</div>
833-
{/* Router mode: show description textarea styled like code editor */}
833+
{/* Router mode: show description textarea with tag/env var support */}
834834
{isRouterMode && (
835-
<Textarea
836-
value={block.value}
837-
onChange={(e) => {
838-
if (!isPreview && !disabled) {
839-
shouldPersistRef.current = true
840-
setConditionalBlocks((blocks) =>
841-
blocks.map((b) =>
842-
b.id === block.id ? { ...b, value: e.target.value } : b
835+
<div
836+
className='relative'
837+
onDragOver={(e) => e.preventDefault()}
838+
onDrop={(e) => handleDrop(block.id, e)}
839+
>
840+
<Textarea
841+
data-router-block-id={block.id}
842+
value={block.value}
843+
onChange={(e) => {
844+
if (!isPreview && !disabled) {
845+
const newValue = e.target.value
846+
const pos = e.target.selectionStart ?? 0
847+
848+
const tagTrigger = checkTagTrigger(newValue, pos)
849+
const envVarTrigger = checkEnvVarTrigger(newValue, pos)
850+
851+
shouldPersistRef.current = true
852+
setConditionalBlocks((blocks) =>
853+
blocks.map((b) =>
854+
b.id === block.id
855+
? {
856+
...b,
857+
value: newValue,
858+
showTags: tagTrigger.show,
859+
showEnvVars: envVarTrigger.show,
860+
searchTerm: envVarTrigger.show ? envVarTrigger.searchTerm : '',
861+
cursorPosition: pos,
862+
}
863+
: b
864+
)
865+
)
866+
}
867+
}}
868+
onBlur={() => {
869+
setTimeout(() => {
870+
setConditionalBlocks((blocks) =>
871+
blocks.map((b) =>
872+
b.id === block.id
873+
? { ...b, showTags: false, showEnvVars: false }
874+
: b
875+
)
876+
)
877+
}, 150)
878+
}}
879+
placeholder='Describe when this route should be taken...'
880+
disabled={disabled || isPreview}
881+
className='min-h-[60px] resize-none rounded-none border-0 px-3 py-2 text-sm placeholder:text-muted-foreground/50 focus-visible:ring-0 focus-visible:ring-offset-0'
882+
rows={2}
883+
/>
884+
885+
{block.showEnvVars && (
886+
<EnvVarDropdown
887+
visible={block.showEnvVars}
888+
onSelect={(newValue) => handleEnvVarSelectImmediate(block.id, newValue)}
889+
searchTerm={block.searchTerm}
890+
inputValue={block.value}
891+
cursorPosition={block.cursorPosition}
892+
workspaceId={workspaceId}
893+
onClose={() => {
894+
setConditionalBlocks((blocks) =>
895+
blocks.map((b) =>
896+
b.id === block.id
897+
? {
898+
...b,
899+
showEnvVars: false,
900+
searchTerm: '',
901+
}
902+
: b
903+
)
843904
)
844-
)
845-
}
846-
}}
847-
placeholder='Describe when this route should be taken...'
848-
disabled={disabled || isPreview}
849-
className='min-h-[60px] resize-none rounded-none border-0 px-3 py-2 text-sm placeholder:text-muted-foreground/50 focus-visible:ring-0 focus-visible:ring-offset-0'
850-
rows={2}
851-
/>
905+
}}
906+
/>
907+
)}
908+
909+
{block.showTags && (
910+
<TagDropdown
911+
visible={block.showTags}
912+
onSelect={(newValue) => handleTagSelectImmediate(block.id, newValue)}
913+
blockId={blockId}
914+
activeSourceBlockId={block.activeSourceBlockId}
915+
inputValue={block.value}
916+
cursorPosition={block.cursorPosition}
917+
onClose={() => {
918+
setConditionalBlocks((blocks) =>
919+
blocks.map((b) =>
920+
b.id === block.id
921+
? {
922+
...b,
923+
showTags: false,
924+
activeSourceBlockId: null,
925+
}
926+
: b
927+
)
928+
)
929+
}}
930+
/>
931+
)}
932+
</div>
852933
)}
853934

854935
{/* Condition mode: show code editor */}

0 commit comments

Comments
 (0)