diff --git a/webapp/channels/src/components/interactive_dialog/dialog_element/dialog_element.test.tsx b/webapp/channels/src/components/interactive_dialog/dialog_element/dialog_element.test.tsx
index 8d48f349ca..ed5c32434c 100644
--- a/webapp/channels/src/components/interactive_dialog/dialog_element/dialog_element.test.tsx
+++ b/webapp/channels/src/components/interactive_dialog/dialog_element/dialog_element.test.tsx
@@ -33,6 +33,32 @@ describe('components/interactive_dialog/DialogElement', () => {
expect(wrapper.find(TextSetting).props().type).toEqual('text');
});
+ describe('subtype number', () => {
+ test('value is 0', () => {
+ const wrapper = shallow(
+ ,
+ );
+ expect(wrapper.find(TextSetting).props().value).toEqual(0);
+ });
+
+ test('value is 123', () => {
+ const wrapper = shallow(
+ ,
+ );
+ expect(wrapper.find(TextSetting).props().value).toEqual(123);
+ });
+ });
+
it('subtype email', () => {
const wrapper = shallow(
;
- value?: string | boolean;
+ value?: string | number | boolean;
onChange: (name: string, selected: string) => void;
autoFocus?: boolean;
actions: {
@@ -163,7 +163,13 @@ export default class DialogElement extends React.PureComponent {
textSettingMaxLength = maxLength || TEXTAREA_DEFAULT_MAX_LENGTH;
}
- const textValue = value as string;
+ let assertedValue;
+ if (subtype === 'number' && typeof value === 'number') {
+ assertedValue = value as number;
+ } else {
+ assertedValue = value as string || '';
+ }
+
return (
{
type={subtype as InputTypes || 'text'}
label={displayNameContent}
maxLength={textSettingMaxLength}
- value={textValue || ''}
+ value={assertedValue}
placeholder={placeholder}
helpText={helpTextContent}
onChange={onChange}
diff --git a/webapp/channels/src/packages/mattermost-redux/src/utils/integration_utils.test.ts b/webapp/channels/src/packages/mattermost-redux/src/utils/integration_utils.test.ts
index 070d3fa31e..3f4e1c58e6 100644
--- a/webapp/channels/src/packages/mattermost-redux/src/utils/integration_utils.test.ts
+++ b/webapp/channels/src/packages/mattermost-redux/src/utils/integration_utils.test.ts
@@ -23,6 +23,10 @@ describe('integration utils', () => {
expect(checkDialogElementForError(TestHelper.getDialogElementMock({type: 'text', min_length: 5}), '123')!.id).toBe('interactive_dialog.error.too_short');
});
+ it('should return null on 0', () => {
+ expect(checkDialogElementForError(TestHelper.getDialogElementMock({type: 'text', subtype: 'number'}), 0)).toBe(null);
+ });
+
it('should return null on good number element', () => {
expect(checkDialogElementForError(TestHelper.getDialogElementMock({type: 'text', subtype: 'number'}), '123')).toBe(null);
});
diff --git a/webapp/channels/src/packages/mattermost-redux/src/utils/integration_utils.ts b/webapp/channels/src/packages/mattermost-redux/src/utils/integration_utils.ts
index c92543bc0b..34be2f5631 100644
--- a/webapp/channels/src/packages/mattermost-redux/src/utils/integration_utils.ts
+++ b/webapp/channels/src/packages/mattermost-redux/src/utils/integration_utils.ts
@@ -9,7 +9,7 @@ type DialogError = {
values?: any;
};
export function checkDialogElementForError(elem: DialogElement, value: any): DialogError | undefined | null {
- if (!value && !elem.optional) {
+ if ((!value && value !== 0) && !elem.optional) {
return {
id: 'interactive_dialog.error.required',
defaultMessage: 'This field is required.',