Skip to content

Commit b300192

Browse files
committed
allow cannonical toggle even if depends on not satisfied
1 parent 3554d7f commit b300192

File tree

1 file changed

+8
-4
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ const getPreviewValue = (
169169
* @param isValidJson - Whether the JSON content is valid (for code blocks)
170170
* @param subBlockValues - Current values of all subblocks for evaluating conditional requirements
171171
* @param wandState - Optional state and handlers for the AI wand feature
172+
* @param canonicalToggle - Optional canonical toggle metadata and handlers
173+
* @param canonicalToggleIsDisabled - Whether the canonical toggle is disabled
172174
* @returns The label JSX element, or `null` for switch types or when no title is defined
173175
*/
174176
const renderLabel = (
@@ -193,15 +195,16 @@ const renderLabel = (
193195
mode: 'basic' | 'advanced'
194196
disabled?: boolean
195197
onToggle?: () => void
196-
}
198+
},
199+
canonicalToggleIsDisabled?: boolean
197200
): JSX.Element | null => {
198201
if (config.type === 'switch') return null
199202
if (!config.title) return null
200203

201204
const required = isFieldRequired(config, subBlockValues)
202205
const showWand = wandState?.isWandEnabled && !wandState.isPreview && !wandState.disabled
203206
const showCanonicalToggle = !!canonicalToggle && !wandState?.isPreview
204-
const canonicalToggleDisabled = wandState?.disabled || canonicalToggle?.disabled
207+
const canonicalToggleDisabledResolved = canonicalToggleIsDisabled ?? canonicalToggle?.disabled
205208

206209
return (
207210
<div className='flex items-center justify-between gap-[6px] pl-[2px]'>
@@ -286,7 +289,7 @@ const renderLabel = (
286289
type='button'
287290
className='flex h-[12px] w-[12px] flex-shrink-0 items-center justify-center bg-transparent p-0 disabled:cursor-not-allowed disabled:opacity-50'
288291
onClick={canonicalToggle?.onToggle}
289-
disabled={canonicalToggleDisabled}
292+
disabled={canonicalToggleDisabledResolved}
290293
aria-label={canonicalToggle?.mode === 'advanced' ? 'Use selector' : 'Enter manual ID'}
291294
>
292295
<ArrowLeftRight
@@ -949,7 +952,8 @@ function SubBlockComponent({
949952
onSearchCancel: handleSearchCancel,
950953
searchInputRef,
951954
},
952-
canonicalToggle
955+
canonicalToggle,
956+
Boolean(canonicalToggle?.disabled || disabled || isPreview)
953957
)}
954958
{renderInput()}
955959
</div>

0 commit comments

Comments
 (0)