[MM-64617] Add enter key press handler to each of the modals (#3463)

This commit is contained in:
Devin Binnie
2025-07-21 09:23:03 -04:00
committed by GitHub
parent af7009535d
commit ecf47e25b7
7 changed files with 8 additions and 2 deletions

View File

@@ -36,6 +36,7 @@ export default function DestructiveConfirmationModal(props: Props) {
modalHeaderText={title}
handleCancel={onCancel}
handleConfirm={onAccept}
handleEnterKeyPress={onAccept}
confirmButtonText={acceptLabel}
cancelButtonText={cancelLabel}
confirmButtonClassName='btn-danger'

View File

@@ -124,7 +124,7 @@ export const Modal: React.FC<Props> = ({
const handleConfirmClick = async (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
event.preventDefault();
if (autoCloseOnConfirmButton) {
if (autoCloseOnConfirmButton && !isConfirmDisabled) {
await onHide();
}
handleConfirm?.();
@@ -135,7 +135,7 @@ export const Modal: React.FC<Props> = ({
if (event.nativeEvent.isComposing) {
return;
}
if (autoCloseOnConfirmButton) {
if (autoCloseOnConfirmButton && !isConfirmDisabled) {
await onHide();
}
if (handleEnterKeyPress) {

View File

@@ -361,6 +361,7 @@ class NewServerModal extends React.PureComponent<Props, State> {
onExited={this.props.unremoveable ? () => {} : this.props.onClose}
modalHeaderText={this.getModalTitle()}
confirmButtonText={this.getSaveButtonLabel()}
handleEnterKeyPress={this.save}
handleConfirm={this.save}
isConfirmDisabled={!this.state.serverName.length || !this.state.validationResult || this.isServerURLErrored()}
handleCancel={this.props.onClose}

View File

@@ -156,6 +156,7 @@ export default function SettingsModal({
defaultMessage='Desktop App Settings'
/>
}
autoCloseOnConfirmButton={false}
headerContent={savingText}
bodyDivider={true}
bodyPadding={false}

View File

@@ -79,6 +79,7 @@ export default class ShowCertificateModal extends React.PureComponent<Props, Sta
/>
}
handleConfirm={this.handleOk}
handleEnterKeyPress={this.handleOk}
>
<dl>
{certificateSection(

View File

@@ -110,6 +110,7 @@ class LoginModal extends React.PureComponent<Props, State> {
/>
}
handleConfirm={this.handleSubmit}
handleEnterKeyPress={this.handleSubmit}
confirmButtonText={
<FormattedMessage
id='label.login'

View File

@@ -104,6 +104,7 @@ class PermissionModal extends React.PureComponent<Props, State> {
onExited={() => {}}
modalHeaderText={this.getModalTitle()}
handleConfirm={this.props.handleGrant}
handleEnterKeyPress={this.props.handleGrant}
confirmButtonText={
<FormattedMessage
id='label.accept'