From 9d4bd0e199e5a5c2856b8aa22eae133cf5c508b3 Mon Sep 17 00:00:00 2001 From: Maxim Khlobystov Date: Tue, 30 Mar 2021 14:33:57 +0000 Subject: [PATCH] Syncing the number of poll options with the drag and drop input --- .../imports/ui/components/poll/component.jsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/bigbluebutton-html5/imports/ui/components/poll/component.jsx b/bigbluebutton-html5/imports/ui/components/poll/component.jsx index c0e6694d7e..5d28bcfe5b 100644 --- a/bigbluebutton-html5/imports/ui/components/poll/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/poll/component.jsx @@ -243,8 +243,21 @@ class Poll extends Component { this.setState({ question: validateInput(e.target.value), error: clearError ? null : error }); } + setOptListLength(len) { + const { optList } = this.state; + const diff = len - optList.length; + if (diff > 0) { + const emptyAddition = Array(diff).fill({ val: '' }); + optList.push(...emptyAddition); + } else { + optList.splice(len); + } + this.setState({ optList }); + } + pushToCustomPollValues(text) { const lines = text.split('\n'); + this.setOptListLength(lines.length); for (let i = 0; i < MAX_CUSTOM_FIELDS; i += 1) { let line = ''; if (i < lines.length) {