|
|
@ -67,9 +67,7 @@ class Poll extends ImmutablePureComponent { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handleOptionChange = e => { |
|
|
|
_toggleOption = value => { |
|
|
|
const { target: { value } } = e; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.props.poll.get('multiple')) { |
|
|
|
if (this.props.poll.get('multiple')) { |
|
|
|
const tmp = { ...this.state.selected }; |
|
|
|
const tmp = { ...this.state.selected }; |
|
|
|
if (tmp[value]) { |
|
|
|
if (tmp[value]) { |
|
|
@ -83,8 +81,20 @@ class Poll extends ImmutablePureComponent { |
|
|
|
tmp[value] = true; |
|
|
|
tmp[value] = true; |
|
|
|
this.setState({ selected: tmp }); |
|
|
|
this.setState({ selected: tmp }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleOptionChange = ({ target: { value } }) => { |
|
|
|
|
|
|
|
this._toggleOption(value); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleOptionKeyPress = (e) => { |
|
|
|
|
|
|
|
if (e.key === 'Enter' || e.key === ' ') { |
|
|
|
|
|
|
|
this._toggleOption(e.target.getAttribute('data-index')); |
|
|
|
|
|
|
|
e.stopPropagation(); |
|
|
|
|
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
handleVote = () => { |
|
|
|
handleVote = () => { |
|
|
|
if (this.props.disabled) { |
|
|
|
if (this.props.disabled) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -135,7 +145,17 @@ class Poll extends ImmutablePureComponent { |
|
|
|
disabled={disabled} |
|
|
|
disabled={disabled} |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
{!showResults && <span className={classNames('poll__input', { checkbox: poll.get('multiple'), active })} />} |
|
|
|
{!showResults && ( |
|
|
|
|
|
|
|
<span |
|
|
|
|
|
|
|
className={classNames('poll__input', { checkbox: poll.get('multiple'), active })} |
|
|
|
|
|
|
|
tabIndex='0' |
|
|
|
|
|
|
|
role={poll.get('multiple') ? 'checkbox' : 'radio'} |
|
|
|
|
|
|
|
onKeyPress={this.handleOptionKeyPress} |
|
|
|
|
|
|
|
aria-checked={active} |
|
|
|
|
|
|
|
aria-label={option.get('title')} |
|
|
|
|
|
|
|
data-index={optionIndex} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
)} |
|
|
|
{showResults && <span className='poll__number'> |
|
|
|
{showResults && <span className='poll__number'> |
|
|
|
{!!voted && <Icon id='check' className='poll__vote__mark' title={intl.formatMessage(messages.voted)} />} |
|
|
|
{!!voted && <Icon id='check' className='poll__vote__mark' title={intl.formatMessage(messages.voted)} />} |
|
|
|
{Math.round(percent)}% |
|
|
|
{Math.round(percent)}% |
|
|
|