Skip to content

Commit 960bf4e

Browse files
nadah09LIT team
authored andcommitted
Fix empty datapoint in datapoint editor to ensure that CategoryLabel dropdown default values are reflected in base data.
PiperOrigin-RevId: 566788498
1 parent 88f1ccb commit 960bf4e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lit_nlp/client/lib/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,10 @@ export function defaultValueByField(key: string, spec: Spec) {
318318
const fieldSpec: LitType = spec[key];
319319
// Explicitly check against undefined, as this value is often false-y if set.
320320
if (fieldSpec.default !== undefined) {
321+
if (fieldSpec instanceof CategoryLabel &&
322+
fieldSpec.vocab && !fieldSpec.vocab.includes(fieldSpec.default)) {
323+
return fieldSpec.vocab[0];
324+
}
321325
return fieldSpec.default;
322326
}
323327
// TODO(lit-dev): remove these and always use the spec default value.

0 commit comments

Comments
 (0)