[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} modalHeaderText={title}
handleCancel={onCancel} handleCancel={onCancel}
handleConfirm={onAccept} handleConfirm={onAccept}
handleEnterKeyPress={onAccept}
confirmButtonText={acceptLabel} confirmButtonText={acceptLabel}
cancelButtonText={cancelLabel} cancelButtonText={cancelLabel}
confirmButtonClassName='btn-danger' confirmButtonClassName='btn-danger'

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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