Skip to content

Commit

Permalink
Added disableEscapeKey and disableCloseOnOutsideClick props to Modal …
Browse files Browse the repository at this point in the history
…(passed in ConfirmRequestClose)
  • Loading branch information
rsilvr committed Jan 3, 2024
1 parent 8309d53 commit 662e7a6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/bruno-app/src/components/Modal/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import StyledWrapper from './StyledWrapper';

const ModalHeader = ({ title, handleCancel }) => (
Expand Down Expand Up @@ -62,6 +62,8 @@ const Modal = ({
confirmDisabled,
hideCancel,
hideFooter,
disableCloseOnOutsideClick,
disableEscapeKey,
closeModalFadeTimeout = 500
}) => {
const [isClosing, setIsClosing] = useState(false);
Expand All @@ -78,6 +80,7 @@ const Modal = ({
};

useEffect(() => {
if (disableEscapeKey) return;
document.addEventListener('keydown', escFunction, false);

return () => {
Expand Down Expand Up @@ -111,9 +114,13 @@ const Modal = ({
{/* Clicking on backdrop closes the modal */}
<div
className="bruno-modal-backdrop"
onClick={() => {
closeModal({ type: 'backdrop' });
}}
onClick={
disableCloseOnOutsideClick
? null
: () => {
closeModal({ type: 'backdrop' });
}
}
/>
</StyledWrapper>
);
Expand Down

0 comments on commit 662e7a6

Please sign in to comment.