Fix composer dropdown toggle buttons (threaded mode and local-only) not working

shrike
Thibaut Girka 2019-09-17 23:40:06 +02:00 committed by ThibG
parent 591185344e
commit ab646fac5f
1 changed files with 5 additions and 8 deletions

View File

@ -77,9 +77,7 @@ export default class ComposerOptionsDropdownContent extends React.PureComponent
document.removeEventListener('touchend', this.handleDocumentClick, withPassive); document.removeEventListener('touchend', this.handleDocumentClick, withPassive);
} }
handleClick = (e) => { handleClick = (name, e) => {
const name = e.currentTarget.getAttribute('data-index');
const { const {
onChange, onChange,
onClose, onClose,
@ -103,9 +101,8 @@ export default class ComposerOptionsDropdownContent extends React.PureComponent
} }
} }
handleKeyDown = e => { handleKeyDown = (name, e) => {
const { items } = this.props; const { items } = this.props;
const name = e.currentTarget.getAttribute('data-index');
const index = items.findIndex(item => { const index = items.findIndex(item => {
return (item.name === name); return (item.name === name);
}); });
@ -183,7 +180,7 @@ export default class ComposerOptionsDropdownContent extends React.PureComponent
let prefix = null; let prefix = null;
if (on !== null && typeof on !== 'undefined') { if (on !== null && typeof on !== 'undefined') {
prefix = <Toggle checked={on} onChange={this.handleClick} />; prefix = <Toggle checked={on} onChange={this.handleClick.bind(this, name)} />;
} else if (icon) { } else if (icon) {
prefix = <Icon className='icon' fixedWidth id={icon} /> prefix = <Icon className='icon' fixedWidth id={icon} />
} }
@ -191,8 +188,8 @@ export default class ComposerOptionsDropdownContent extends React.PureComponent
return ( return (
<div <div
className={computedClass} className={computedClass}
onClick={this.handleClick} onClick={this.handleClick.bind(this, name)}
onKeyDown={this.handleKeyDown} onKeyDown={this.handleKeyDown.bind(this, name)}
role='option' role='option'
tabIndex='0' tabIndex='0'
key={name} key={name}