Skip to content

Commit 565055c

Browse files
authored
fix: Fix input-slider value parsing from metadata (#180)
* fix: Fix input-slider value parsing from metadata Signed-off-by: Tomas Kislan <tomas@kislan.sk> * fix: Remove forgotten debug console.log Signed-off-by: Tomas Kislan <tomas@kislan.sk> --------- Signed-off-by: Tomas Kislan <tomas@kislan.sk>
1 parent 821aadd commit 565055c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/notebooks/deepnote/inputBlockContentFormatter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* This is the single source of truth for how input block values are displayed in cells.
44
*/
55

6+
import z from 'zod';
7+
68
/**
79
* Gets the expected language ID for an input block type.
810
* This is the single source of truth for input block language modes.
@@ -57,7 +59,8 @@ export function formatInputBlockCellContent(blockType: string, metadata: Record<
5759

5860
case 'input-slider': {
5961
const value = metadata.deepnote_variable_value;
60-
return typeof value === 'number' ? String(value) : '';
62+
const parsedValueResult = z.coerce.number().safeParse(value);
63+
return parsedValueResult.success ? String(parsedValueResult.data) : '';
6164
}
6265

6366
case 'input-checkbox': {

0 commit comments

Comments
 (0)