From 26490e56a14b068f7eec4da3d051169eca476d6f Mon Sep 17 00:00:00 2001 From: TJ Durnford Date: Thu, 9 Jan 2020 09:30:10 -0800 Subject: [PATCH 1/2] Fixed multiple choice type undo/redo functionality --- .../PromptField/ChoiceInput/Choices.tsx | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Composer/packages/extensions/obiformeditor/src/Form/fields/PromptField/ChoiceInput/Choices.tsx b/Composer/packages/extensions/obiformeditor/src/Form/fields/PromptField/ChoiceInput/Choices.tsx index 07d0de270d..bb758a9a9f 100644 --- a/Composer/packages/extensions/obiformeditor/src/Form/fields/PromptField/ChoiceInput/Choices.tsx +++ b/Composer/packages/extensions/obiformeditor/src/Form/fields/PromptField/ChoiceInput/Choices.tsx @@ -3,7 +3,7 @@ /** @jsx jsx */ import { jsx } from '@emotion/core'; -import React, { useCallback, useMemo, useState } from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { Dropdown, ResponsiveMode } from 'office-ui-fabric-react/lib/Dropdown'; import { JSONSchema6 } from 'json-schema'; import { IChoice } from '@bfc/shared'; @@ -47,6 +47,10 @@ export const Choices: React.FC = props => { [choiceType, onchange, setChoiceType] ); + useEffect(() => { + setChoiceType(Array.isArray(formData ?? []) && typeof formData !== 'string' ? 'static' : 'dynamic'); + }, [formData]); + return (
@@ -60,19 +64,21 @@ export const Choices: React.FC = props => { } id={id} /> - + {options.length > 0 && ( + + )}
- {choiceType === 'static' ? ( + {!options || choiceType === 'static' ? ( ) : ( From 733530d117e17b3e88857f3c2d7d602b3581cc0e Mon Sep 17 00:00:00 2001 From: TJ Durnford Date: Thu, 9 Jan 2020 09:39:55 -0800 Subject: [PATCH 2/2] Fixed input width --- .../obiformeditor/src/Form/ArrayFieldTemplate/StringArray.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/Composer/packages/extensions/obiformeditor/src/Form/ArrayFieldTemplate/StringArray.tsx b/Composer/packages/extensions/obiformeditor/src/Form/ArrayFieldTemplate/StringArray.tsx index 636fde1437..15904a4db8 100644 --- a/Composer/packages/extensions/obiformeditor/src/Form/ArrayFieldTemplate/StringArray.tsx +++ b/Composer/packages/extensions/obiformeditor/src/Form/ArrayFieldTemplate/StringArray.tsx @@ -53,6 +53,7 @@ const StringArray: React.FunctionComponent = props => { iconName: 'ReturnKey', style: { color: SharedColors.cyanBlue10, opacity: 0.6 }, }} + styles={{ root: { width: '100%' } }} data-testid="string-array-text-input" />