Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions __tests__/Unit/Components/Tasks/TaskUpdateModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ describe('TaskUpdateModal', () => {
expect(mockOnUpdateSuccess).toHaveBeenCalled();
expect(mockSetIsOpen).toHaveBeenCalledWith(false);
});

it('should call the setIsOpen when close button is clicked', async () => {
renderWithRouter(
<Provider store={store()}>
Expand All @@ -197,26 +196,4 @@ describe('TaskUpdateModal', () => {
fireEvent.click(closeButton);
expect(mockSetIsOpen).toHaveBeenCalledWith(false);
});

it('should show the close button when dev is true', () => {
renderWithRouter(<TaskUpdateModal {...defaultProps} />, {
query: { dev: 'true' },
});

const closeButton = screen.getByTestId(
'task-update-modal-close-button'
);
expect(closeButton).toBeInTheDocument();
});

it('should not show the close button when dev is false', async () => {
renderWithRouter(<TaskUpdateModal {...defaultProps} />, {
query: { dev: 'false' },
});

const closeButton = screen.queryByTestId(
'task-update-modal-close-button'
);
expect(closeButton).not.toBeInTheDocument();
});
});
22 changes: 8 additions & 14 deletions src/components/taskDetails/TaskUpdateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import getCurrentDate from '@/utils/getLatestDate';
import { questions } from '@/constants/ProgressUpdates';
import ProgressForm from '../ProgressForm/ProgressForm';
import task from '@/interfaces/task.type';
import { useRouter } from 'next/router';
import { IoMdClose } from 'react-icons/io';
type Props = {
isOpen: boolean;
Expand All @@ -26,22 +25,17 @@ function TaskUpdateModal({
editedTaskDetails,
onUpdateSuccess,
}: Props) {
const router = useRouter();
const { dev } = router.query;

return (
<Modal isOpen={isOpen} toggle={() => setIsOpen(false)}>
<div className={styles.taskUpdateModal}>
{dev === 'true' && (
<button
className={styles.closeButton}
onClick={() => setIsOpen(false)}
data-testid="task-update-modal-close-button"
aria-label="Close"
>
<IoMdClose size={25} />
</button>
)}
<button
className={styles.closeButton}
onClick={() => setIsOpen(false)}
data-testid="task-update-modal-close-button"
aria-label="Close"
>
<IoMdClose size={25} />
</button>
Comment on lines +31 to +38
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add explicit button type for accessibility.

The close button implementation is good, but it's missing an explicit type attribute which is required for accessibility compliance.

<button
    className={styles.closeButton}
    onClick={() => setIsOpen(false)}
    data-testid="task-update-modal-close-button"
    aria-label="Close"
+   type="button"
>
    <IoMdClose size={25} />
</button>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<button
className={styles.closeButton}
onClick={() => setIsOpen(false)}
data-testid="task-update-modal-close-button"
aria-label="Close"
>
<IoMdClose size={25} />
</button>
<button
className={styles.closeButton}
onClick={() => setIsOpen(false)}
data-testid="task-update-modal-close-button"
aria-label="Close"
type="button"
>
<IoMdClose size={25} />
</button>
🧰 Tools
🪛 Biome (1.9.4)

[error] 31-36: Provide an explicit type prop for the button element.

The default type of a button is submit, which causes the submission of a form when placed inside a form element. This is likely not the behaviour that you want inside a React application.
Allowed button types are: submit, button or reset

(lint/a11y/useButtonType)

<h3 className={styles.updateProgress}>Update Progress</h3>
<section className={styles.containerUpdate}>
<h1 className={styles.formHeading}>Task Updates</h1>
Expand Down