Skip to content

Commit 59cad83

Browse files
committed
fix: Fix input-slider value parsing from metadata
Signed-off-by: Tomas Kislan <tomas@kislan.sk>
1 parent 821aadd commit 59cad83

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/notebooks/deepnote/inputBlockContentFormatter.ts

Lines changed: 5 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.
@@ -29,6 +31,7 @@ export function getInputBlockLanguage(blockType: string): string | undefined {
2931
* @returns The formatted cell content string
3032
*/
3133
export function formatInputBlockCellContent(blockType: string, metadata: Record<string, unknown>): string {
34+
console.log('formatInputBlockCellContent', blockType, metadata);
3235
switch (blockType) {
3336
case 'input-text':
3437
case 'input-textarea': {
@@ -57,7 +60,8 @@ export function formatInputBlockCellContent(blockType: string, metadata: Record<
5760

5861
case 'input-slider': {
5962
const value = metadata.deepnote_variable_value;
60-
return typeof value === 'number' ? String(value) : '';
63+
const parsedValueResult = z.coerce.number().safeParse(value);
64+
return parsedValueResult.success ? String(parsedValueResult.data) : '';
6165
}
6266

6367
case 'input-checkbox': {

0 commit comments

Comments
 (0)