Skip to content

Commit bbacd20

Browse files
committed
Properly return values from list form item
1 parent 6d54b83 commit bbacd20

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

src/components/chat-item/chat-item-form-items.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ export class ChatItemFormItemsWrapper {
348348
this.onAllFormItemsDisabled?.();
349349
};
350350

351-
getAllValues = (): Record<string, string> => {
352-
const valueMap: Record<string, string> = {};
351+
getAllValues = (): Record<string, string | string[]> => {
352+
const valueMap: Record<string, string | string[]> = {};
353353
Object.keys(this.options).forEach(chatOptionId => {
354354
valueMap[chatOptionId] = this.options[chatOptionId].getValue();
355355
});

src/components/chat-item/prompt-input/prompt-options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class PromptOptions {
7777
});
7878
};
7979

80-
public readonly getOptionValues = (): Record<string, string> => {
80+
public readonly getOptionValues = (): Record<string, string | string[]> => {
8181
return this.formItemsWrapper?.getAllValues() ?? {};
8282
};
8383
}

src/components/feedback-form/feedback-form.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class FeedbackForm {
162162
chatItem: Partial<ChatItem>;
163163
title?: string;
164164
description?: string;
165-
onFormAction?: (actionName: string, formData: Record<string, string>) => void;
165+
onFormAction?: (actionName: string, formData: Record<string, string | string[]>) => void;
166166
onFormDisabled?: () => void;
167167
onCloseButtonClick?: (e: Event) => void;
168168
}): Array<ExtendedHTMLElement | HTMLElement | string | DomBuilderObject> => {

src/components/form-items/form-item-list.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ export interface FormItemListProps {
2121
label?: HTMLElement | ExtendedHTMLElement | string;
2222
description?: ExtendedHTMLElement;
2323
wrapperTestId?: string;
24-
onChange?: (values: string) => void;
24+
onChange?: (values: string[]) => void;
2525
}
2626

2727
export abstract class FormItemListAbstract {
2828
render: ExtendedHTMLElement;
2929
setValue = (value: ListItemEntry[]): void => { };
30-
getValue = (): string => '';
30+
getValue = (): string[] => [];
3131
setEnabled = (enabled: boolean): void => { };
3232
}
3333

@@ -176,9 +176,8 @@ export class FormItemListInternal extends FormItemListAbstract {
176176
}
177177
};
178178

179-
getValue = (): string => {
180-
// TODO: Implement this properly
181-
return Object.values(this.formData).join(',');
179+
getValue = (): string[] => {
180+
return Object.values(this.formData);
182181
};
183182

184183
setEnabled = (enabled: boolean): void => {
@@ -195,6 +194,6 @@ export class FormItemList extends FormItemListAbstract {
195194
}
196195

197196
setValue = (value: ListItemEntry[]): void => { };
198-
getValue = (): string => '';
197+
getValue = (): string[] => [];
199198
setEnabled = (enabled: boolean): void => { };
200199
}

src/static.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ export interface ChatPrompt {
489489
prompt?: string;
490490
escapedPrompt?: string;
491491
command?: string;
492-
options?: Record<string, string>;
492+
options?: Record<string, string | string[]>;
493493
context?: string[] | QuickActionCommand[];
494494
}
495495

0 commit comments

Comments
 (0)