Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(polls): Disable submit button if no answers have been chosen
Vlad Piersec7f4fb7f447de
diff --git a/css/_polls.scss b/css/_polls.scssindex 178192dd74..f4b49b5442 100644--- a/css/_polls.scss+++ b/css/_polls.scss@@ -406,6 +406,7 @@ a.poll-detail-link, a.poll-change-vote-link {&:disabled {background-color: #00225A;color: #858585;+ cursor: default;}& > *:not(:last-child) {diff --git a/react/features/polls/components/native/PollAnswer.js b/react/features/polls/components/native/PollAnswer.jsindex ba5067649b..2bbf4b5474 100644--- a/react/features/polls/components/native/PollAnswer.js+++ b/react/features/polls/components/native/PollAnswer.js@@ -5,6 +5,7 @@ import { Switch, Text, View } from 'react-native';import { Button } from 'react-native-paper';import { BUTTON_MODES } from '../../../chat/constants';+import { isSubmitAnswerDisabled } from '../../functions';import AbstractPollAnswer from '../AbstractPollAnswer';import type { AbstractProps } from '../AbstractPollAnswer';@@ -12,7 +13,6 @@ import { chatStyles, dialogStyles } from './styles';const PollAnswer = (props: AbstractProps) => {-const {checkBoxStates,poll,@@ -50,6 +50,7 @@ const PollAnswer = (props: AbstractProps) => {</Button><Buttoncolor = '#17a0db'+ disabled = { isSubmitAnswerDisabled(checkBoxStates) }mode = { BUTTON_MODES.CONTAINED }onPress = { submitAnswer }style = { chatStyles.pollCreateButton } >diff --git a/react/features/polls/components/web/PollAnswer.js b/react/features/polls/components/web/PollAnswer.jsindex 01ebbf3328..2e2f5ad86e 100644--- a/react/features/polls/components/web/PollAnswer.js+++ b/react/features/polls/components/web/PollAnswer.js@@ -3,12 +3,11 @@import { Checkbox } from '@atlaskit/checkbox';import React from 'react';+import { isSubmitAnswerDisabled } from '../../functions';import AbstractPollAnswer from '../AbstractPollAnswer';import type { AbstractProps } from '../AbstractPollAnswer';-const PollAnswer = (props: AbstractProps) => {-const {checkBoxStates,poll,@@ -51,7 +50,8 @@ const PollAnswer = (props: AbstractProps) => {</button><buttonaria-label = { t('polls.answer.submit') }- className = { 'poll-small-primary-button' }+ className = 'poll-small-primary-button'+ disabled = { isSubmitAnswerDisabled(checkBoxStates) }onClick = { submitAnswer }><span>{t('polls.answer.submit')}</span></button>diff --git a/react/features/polls/functions.js b/react/features/polls/functions.jsindex c9f83bde16..1ff80af1f9 100644--- a/react/features/polls/functions.js+++ b/react/features/polls/functions.js@@ -21,3 +21,13 @@ export function getUnreadPollCount(state: Object) {return nbUnreadPolls;}++/**+ * Determines if the submit poll answer button should be disabled.+ *+ * @param {Array<boolean>} checkBoxStates - The states of the checkboxes.+ * @returns {boolean}+ */+export function isSubmitAnswerDisabled(checkBoxStates: Array<boolean>) {+ return !checkBoxStates.find(checked => checked);+}