mirror of https://github.com/vector-im/riot-web
Allow closing Dropdown via its chevron
parent
c3bac33b9d
commit
ad5842c87a
|
@ -178,6 +178,14 @@ export default class Dropdown extends React.Component<IProps, IState> {
|
||||||
this.ignoreEvent = ev;
|
this.ignoreEvent = ev;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private onChevronClick = (ev: React.MouseEvent) => {
|
||||||
|
if (this.state.expanded) {
|
||||||
|
this.setState({ expanded: false });
|
||||||
|
ev.stopPropagation();
|
||||||
|
ev.preventDefault();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private onAccessibleButtonClick = (ev: ButtonEvent) => {
|
private onAccessibleButtonClick = (ev: ButtonEvent) => {
|
||||||
if (this.props.disabled) return;
|
if (this.props.disabled) return;
|
||||||
|
|
||||||
|
@ -375,7 +383,7 @@ export default class Dropdown extends React.Component<IProps, IState> {
|
||||||
onKeyDown={this.onKeyDown}
|
onKeyDown={this.onKeyDown}
|
||||||
>
|
>
|
||||||
{ currentValue }
|
{ currentValue }
|
||||||
<span className="mx_Dropdown_arrow" />
|
<span onClick={this.onChevronClick} className="mx_Dropdown_arrow" />
|
||||||
{ menu }
|
{ menu }
|
||||||
</AccessibleButton>
|
</AccessibleButton>
|
||||||
</div>;
|
</div>;
|
||||||
|
|
Loading…
Reference in New Issue