Don't reload the page when user hits enter when entering ban reason (#7145)

This commit is contained in:
Michael Telatynski 2021-11-16 14:45:59 +00:00 committed by GitHub
parent 734ce97135
commit edfebdcdfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React, { ChangeEvent, ReactNode } from 'react'; import React, { ChangeEvent, FormEvent, ReactNode } from 'react';
import { MatrixClient } from 'matrix-js-sdk/src/client'; import { MatrixClient } from 'matrix-js-sdk/src/client';
import { RoomMember } from "matrix-js-sdk/src/models/room-member"; import { RoomMember } from "matrix-js-sdk/src/models/room-member";
import classNames from "classnames"; import classNames from "classnames";
@ -76,7 +76,8 @@ export default class ConfirmUserActionDialog extends React.Component<IProps, ISt
}; };
} }
private onOk = (): void => { private onOk = (ev: FormEvent): void => {
ev.preventDefault();
this.props.onFinished(true, this.state.reason); this.props.onFinished(true, this.state.reason);
}; };
@ -144,7 +145,8 @@ export default class ConfirmUserActionDialog extends React.Component<IProps, ISt
{ reasonBox } { reasonBox }
{ this.props.children } { this.props.children }
</div> </div>
<DialogButtons primaryButton={this.props.action} <DialogButtons
primaryButton={this.props.action}
onPrimaryButtonClick={this.onOk} onPrimaryButtonClick={this.onOk}
primaryButtonClass={confirmButtonClass} primaryButtonClass={confirmButtonClass}
focus={!this.props.askReason} focus={!this.props.askReason}