Skip to content
Snippets Groups Projects
Unverified Commit 2955fed1 authored by Anton Georgiev's avatar Anton Georgiev Committed by GitHub
Browse files

Merge pull request #11895 from MaximKhlobystov/sync-options-length-dragndrop

Syncing the length of poll options list with the drag and drop input
parents c9b5e3d6 1da39201
No related branches found
No related tags found
No related merge requests found
......@@ -243,8 +243,24 @@ class Poll extends Component {
this.setState({ question: validateInput(e.target.value), error: clearError ? null : error });
}
setOptListLength(len) {
const { optList } = this.state;
len = len > MAX_CUSTOM_FIELDS ? MAX_CUSTOM_FIELDS : len;
let diff = len - optList.length;
if(diff > 0) {
while(diff--) {
this.handleAddOption();
}
} else {
while(diff++) {
this.handleRemoveOption();
}
}
}
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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment