Add 1000 char limit to questions & answers

This commit is contained in:
Vlad Piersec 2021-10-15 12:59:20 +03:00 committed by vp8x8
parent 97ea155905
commit bb8bc2fe32
3 changed files with 8 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import { Button } from 'react-native-paper';
import { Icon, IconClose } from '../../../base/icons';
import { BUTTON_MODES } from '../../../chat/constants';
import { CHAR_LIMIT } from '../../constants';
import AbstractPollCreate from '../AbstractPollCreate';
import type { AbstractProps } from '../AbstractPollCreate';
@ -105,6 +106,7 @@ const PollCreate = (props: AbstractProps) => {
style = { dialogStyles.optionContainer }>
<TextInput
blurOnSubmit = { false }
maxLength = { CHAR_LIMIT }
multiline = { true }
onChangeText = { text => setAnswer(index, text) }
onKeyPress = { ev => onAnswerKeyDown(index, ev) }
@ -125,6 +127,7 @@ const PollCreate = (props: AbstractProps) => {
<TextInput
autoFocus = { true }
blurOnSubmit = { false }
maxLength = { CHAR_LIMIT }
multiline = { true }
onChangeText = { setQuestion }
onSubmitEditing = { onQuestionKeyDown }

View File

@ -4,10 +4,10 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
import { Icon, IconMenu } from '../../../base/icons';
import { Tooltip } from '../../../base/tooltip';
import { CHAR_LIMIT } from '../../constants';
import AbstractPollCreate from '../AbstractPollCreate';
import type { AbstractProps } from '../AbstractPollCreate';
const PollCreate = (props: AbstractProps) => {
@ -158,6 +158,7 @@ const PollCreate = (props: AbstractProps) => {
<textarea
autoFocus = { true }
className = 'expandable-input'
maxLength = { CHAR_LIMIT }
onChange = { ev => setQuestion(ev.target.value) }
onInput = { autogrow }
onKeyDown = { onQuestionKeyDown }
@ -178,6 +179,7 @@ const PollCreate = (props: AbstractProps) => {
<div className = 'poll-create-option-row'>
<textarea
className = 'expandable-input'
maxLength = { CHAR_LIMIT }
onChange = { ev => setAnswer(i, ev.target.value) }
onInput = { autogrow }
onKeyDown = { ev => onAnswerKeyDown(i, ev) }

View File

@ -3,3 +3,5 @@
export const COMMAND_NEW_POLL = 'new-poll';
export const COMMAND_ANSWER_POLL = 'answer-poll';
export const COMMAND_OLD_POLLS = 'old-polls';
export const CHAR_LIMIT = 1000;