Skip to content

Commit b04f5f2

Browse files
committed
fix empty value handling for multi-select inputs
1 parent a3fb707 commit b04f5f2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/notebooks/deepnote/deepnoteInputBlockCellStatusBarProvider.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,10 +738,25 @@ export class DeepnoteInputBlockCellStatusBarItemProvider
738738
void this.updateCellMetadata(cell, { deepnote_variable_value: [] });
739739
}
740740
});
741+
} else {
742+
// If empty values are not allowed, ensure at least one item is always selected
743+
quickPick.onDidChangeSelection((selectedItems) => {
744+
if (selectedItems.length === 0) {
745+
// Prevent deselecting the last item - restore previous selection
746+
quickPick.selectedItems = optionItems.filter((item) => item.picked);
747+
}
748+
});
741749
}
742750

743751
quickPick.onDidAccept(() => {
744752
const selected = quickPick.selectedItems;
753+
754+
// If empty values are not allowed, ensure at least one item is selected
755+
if (!allowEmpty && selected.length === 0) {
756+
void window.showWarningMessage(l10n.t('At least one option must be selected'));
757+
return;
758+
}
759+
745760
const newValue = selected.map((item) => item.label);
746761
void this.updateCellMetadata(cell, { deepnote_variable_value: newValue });
747762
quickPick.hide();

0 commit comments

Comments
 (0)