Skip to content

Commit

Permalink
Fix close button in QueryStackTraceModal (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdametto authored Jan 31, 2024
1 parent b4e7876 commit 5f15a70
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Fix close button in QueryStackTraceModal

## 2024-01-31 - 0.4.2

- Export missing useButtonStyles function.
Expand Down
12 changes: 12 additions & 0 deletions src/components/QueryStackTraceModal/QueryStackTraceModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,16 @@ describe('The "QueryStackTraceModal" component', () => {

expect(onCloseSpy).toHaveBeenCalled();
});

it('closes if the "x" button is clicked', async () => {
const { user } = setup();

await user.click(
screen
.getAllByRole('button')
.find(el => el.classList.contains('ant-modal-close'))!,
);

expect(onCloseSpy).toHaveBeenCalled();
});
});
11 changes: 3 additions & 8 deletions src/components/QueryStackTraceModal/QueryStackTraceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SyntaxHighlighter from '../SyntaxHighlighter';
export type QueryStackTraceModalProps = {
modalTitle: string;
visible?: boolean;
onClose?: () => void;
onClose: () => void;
query: string;
queryError: string;
};
Expand All @@ -17,17 +17,12 @@ function QueryStackTraceModal({
query,
queryError,
}: QueryStackTraceModalProps) {
const onOk = () => {
if (onClose) {
onClose();
}
};

return (
<Modal
title={modalTitle}
open={visible}
onOk={onOk}
onOk={onClose}
onCancel={onClose}
width="80%"
footer={
<div>
Expand Down

0 comments on commit 5f15a70

Please sign in to comment.