Skip to content

Commit

Permalink
fix input blocks sometimes not updating
Browse files Browse the repository at this point in the history
  • Loading branch information
vieiralucas committed Jan 4, 2025
1 parent ca85064 commit b36ce22
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,13 @@ function DateInput(props: Props) {
props.userId,
environmentStartedAt
)
}, [props.block, props.blocks, props.executionQueue, props.userId])
}, [
props.block,
props.blocks,
props.executionQueue,
props.userId,
environmentStartedAt,
])

const onChangeVariable: React.ChangeEventHandler<HTMLInputElement> =
useCallback(
Expand All @@ -120,7 +126,7 @@ function DateInput(props: Props) {
updateDateInputBlockDateType(props.block, props.blocks, type)
onRun()
},
[props.block, onRun]
[props.block, props.blocks, onRun]
)

const onChangeTimeZone = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ type Props = {
export default function DropdownSettings(props: Props) {
const attrs = getDropdownInputAttributes(props.block, props.blocks)

const onChangeDropdownType = useCallback((type: 'static' | 'dynamic') => {
setDropdownType(props.block, type)
}, [])
const onChangeDropdownType = useCallback(
(type: 'static' | 'dynamic') => {
setDropdownType(props.block, type)
},
[props.block]
)

return (
<div className="bg-gray-50 px-3 py-3 border border-gray-200 flex flex-col gap-y-2 rounded-md shadow-sm">
Expand Down Expand Up @@ -273,7 +276,7 @@ const DynamicInput = (props: DynamicInputProps) => {
(col) => col.name === attrs.columnName
)
const categories =
currCol && 'categories' in currCol ? currCol.categories ?? [] : []
currCol && 'categories' in currCol ? (currCol.categories ?? []) : []
appendDropdownInputOptions(
props.block,
props.blocks,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,14 @@ function DropdownInputBlock(props: Props) {
)
}
},
[props.block, props.userId, props.executionQueue]
[
attrs.variable.newValue,
attrs.variable.value,
props.block,
props.blocks,
props.executionQueue,
environmentStartedAt,
]
)

const onRetryVariable = useCallback(() => {
Expand All @@ -162,7 +169,13 @@ function DropdownInputBlock(props: Props) {
_tag: 'dropdown-input-rename-variable',
}
)
}, [props.block, props.userId, props.executionQueue, environmentStartedAt])
}, [
props.block,
props.blocks,
props.executionQueue,
props.userId,
environmentStartedAt,
])

const selectRef = useRef<HTMLUListElement>(null)

Expand Down Expand Up @@ -216,7 +229,7 @@ function DropdownInputBlock(props: Props) {
}
)
},
[props.block, props.userId, props.executionQueue, environmentStartedAt]
[props.block, props.executionQueue, props.userId, environmentStartedAt]
)

const onRun = useCallback(() => {
Expand Down
20 changes: 17 additions & 3 deletions apps/web/src/components/v2Editor/customBlocks/input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,15 @@ function InputBlock(props: Props) {
)
}
},
[props.block, props.userId, environmentStartedAt]
[
attrs.variable.newValue,
attrs.variable.value,
props.block,
props.blocks,
props.executionQueue,
props.userId,
environmentStartedAt,
]
)

const onSaveValue = useCallback(() => {
Expand All @@ -129,7 +137,7 @@ function InputBlock(props: Props) {
_tag: 'text-input-save-value',
}
)
}, [props.block, props.userId, environmentStartedAt])
}, [props.executionQueue, props.block, props.userId, environmentStartedAt])

const onRunValue = useCallback(() => {
updateInputVariable(props.block, props.blocks, {
Expand All @@ -144,7 +152,13 @@ function InputBlock(props: Props) {
_tag: 'text-input-rename-variable',
}
)
}, [props.block, props.userId, environmentStartedAt])
}, [
props.block,
props.blocks,
props.executionQueue,
props.userId,
environmentStartedAt,
])

const variableExecutions = useBlockExecutions(
props.executionQueue,
Expand Down

0 comments on commit b36ce22

Please sign in to comment.