mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Implement Jira Ticket PLT-6555 - Enter should confirm deletion on delete modals (#6375)
This commit is contained in:
committed by
Harrison Healey
parent
a5d2d6503d
commit
d07e4068b4
@@ -11,12 +11,14 @@ import {browserHistory} from 'react-router/es6';
|
||||
import React from 'react';
|
||||
|
||||
import {deleteChannel} from 'actions/channel_actions.jsx';
|
||||
import Constants from 'utils/constants.jsx';
|
||||
|
||||
export default class DeleteChannelModal extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.handleDelete = this.handleDelete.bind(this);
|
||||
this.handleKeyDown = this.handleKeyDown.bind(this);
|
||||
this.onHide = this.onHide.bind(this);
|
||||
|
||||
this.state = {show: true};
|
||||
@@ -35,12 +37,19 @@ export default class DeleteChannelModal extends React.Component {
|
||||
this.setState({show: false});
|
||||
}
|
||||
|
||||
handleKeyDown(e) {
|
||||
if (e.keyCode === Constants.KeyCodes.ENTER) {
|
||||
this.handleDelete();
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Modal
|
||||
show={this.state.show}
|
||||
onHide={this.onHide}
|
||||
onExited={this.props.onHide}
|
||||
onKeyDown={this.handleKeyDown}
|
||||
>
|
||||
<Modal.Header closeButton={true}>
|
||||
<h4 className='modal-title'>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
|
||||
import ConfirmModal from './confirm_modal.jsx';
|
||||
import Constants from 'utils/constants.jsx';
|
||||
|
||||
export default class DeleteModalTrigger extends React.Component {
|
||||
constructor(props) {
|
||||
@@ -11,6 +12,7 @@ export default class DeleteModalTrigger extends React.Component {
|
||||
this.handleConfirm = this.handleConfirm.bind(this);
|
||||
this.handleCancel = this.handleCancel.bind(this);
|
||||
this.handleOpenModal = this.handleOpenModal.bind(this);
|
||||
this.handleKeyDown = this.handleKeyDown.bind(this);
|
||||
|
||||
this.state = {
|
||||
showDeleteModal: false
|
||||
@@ -35,6 +37,12 @@ export default class DeleteModalTrigger extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
handleKeyDown(e) {
|
||||
if (e.keyCode === Constants.KeyCodes.ENTER) {
|
||||
this.handleConfirm(e);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<span>
|
||||
@@ -51,6 +59,7 @@ export default class DeleteModalTrigger extends React.Component {
|
||||
confirmButton={this.modalConfirmButton}
|
||||
onConfirm={this.handleConfirm}
|
||||
onCancel={this.handleCancel}
|
||||
onKeyDown={this.handleKeyDown}
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
|
||||
@@ -26,9 +26,7 @@ export default class EmojiListItem extends React.Component {
|
||||
this.handleDelete = this.handleDelete.bind(this);
|
||||
}
|
||||
|
||||
handleDelete(e) {
|
||||
e.preventDefault();
|
||||
|
||||
handleDelete() {
|
||||
this.props.onDelete(this.props.emoji);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user