Skip to content

Commit 20fca88

Browse files
[MM-64617] Add enter key press handler to each of the modals (#3463) (#3467)
(cherry picked from commit ecf47e2) Co-authored-by: Devin Binnie <52460000+devinbinnie@users.noreply.github.com>
1 parent 7f91463 commit 20fca88

7 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/renderer/components/DestructiveConfirmModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default function DestructiveConfirmationModal(props: Props) {
3636
modalHeaderText={title}
3737
handleCancel={onCancel}
3838
handleConfirm={onAccept}
39+
handleEnterKeyPress={onAccept}
3940
confirmButtonText={acceptLabel}
4041
cancelButtonText={cancelLabel}
4142
confirmButtonClassName='btn-danger'

src/renderer/components/Modal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export const Modal: React.FC<Props> = ({
124124

125125
const handleConfirmClick = async (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
126126
event.preventDefault();
127-
if (autoCloseOnConfirmButton) {
127+
if (autoCloseOnConfirmButton && !isConfirmDisabled) {
128128
await onHide();
129129
}
130130
handleConfirm?.();
@@ -135,7 +135,7 @@ export const Modal: React.FC<Props> = ({
135135
if (event.nativeEvent.isComposing) {
136136
return;
137137
}
138-
if (autoCloseOnConfirmButton) {
138+
if (autoCloseOnConfirmButton && !isConfirmDisabled) {
139139
await onHide();
140140
}
141141
if (handleEnterKeyPress) {

src/renderer/components/NewServerModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ class NewServerModal extends React.PureComponent<Props, State> {
361361
onExited={this.props.unremoveable ? () => {} : this.props.onClose}
362362
modalHeaderText={this.getModalTitle()}
363363
confirmButtonText={this.getSaveButtonLabel()}
364+
handleEnterKeyPress={this.save}
364365
handleConfirm={this.save}
365366
isConfirmDisabled={!this.state.serverName.length || !this.state.validationResult || this.isServerURLErrored()}
366367
handleCancel={this.props.onClose}

src/renderer/components/SettingsModal/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export default function SettingsModal({
156156
defaultMessage='Desktop App Settings'
157157
/>
158158
}
159+
autoCloseOnConfirmButton={false}
159160
headerContent={savingText}
160161
bodyDivider={true}
161162
bodyPadding={false}

src/renderer/components/showCertificateModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export default class ShowCertificateModal extends React.PureComponent<Props, Sta
7979
/>
8080
}
8181
handleConfirm={this.handleOk}
82+
handleEnterKeyPress={this.handleOk}
8283
>
8384
<dl>
8485
{certificateSection(

src/renderer/modals/login/loginModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class LoginModal extends React.PureComponent<Props, State> {
110110
/>
111111
}
112112
handleConfirm={this.handleSubmit}
113+
handleEnterKeyPress={this.handleSubmit}
113114
confirmButtonText={
114115
<FormattedMessage
115116
id='label.login'

src/renderer/modals/permission/permissionModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class PermissionModal extends React.PureComponent<Props, State> {
104104
onExited={() => {}}
105105
modalHeaderText={this.getModalTitle()}
106106
handleConfirm={this.props.handleGrant}
107+
handleEnterKeyPress={this.props.handleGrant}
107108
confirmButtonText={
108109
<FormattedMessage
109110
id='label.accept'

0 commit comments

Comments
 (0)