Skip to content

Commit

Permalink
Make sure not to trigger parent events in MaterialInfo component
Browse files Browse the repository at this point in the history
When clicking on the title, two modals would open - one event triggered
by clicking the title on the card, and the other triggered by the card
itself.
  • Loading branch information
Adamik10 committed Dec 7, 2023
1 parent cfe8235 commit 2da7690
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ const AdditionalMaterialsButton: FC<AdditionalMaterialsButtonProps> = ({
<button
type="button"
onClick={(e) => openDueDateModalCallBack(e)}
onKeyUp={(e) => {
if (e.key === "Enter" || e.key === "Space") {
openDueDateModalCallBack(e as unknown as MouseEvent);
}
}}
// in loan-list-items.tsx
aria-describedby="materials-modal-text"
className={`list-reservation__note list-reservation__note--${showOn}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ const MaterialInfo: FC<MaterialInfoProps> = ({
</div>
<div className="list-reservation__about">
<button
onClick={() => openDetailsModal()}
onClick={(e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
e.stopPropagation();
openDetailsModal();
}}
onKeyUp={(e) => {
if (e.key === "Enter" || e.key === "Space") {
e.stopPropagation();
openDetailsModal();
}
}}
type="button"
// This is to handle focus when more items are loaded via pagination
// eslint-disable-next-line jsx-a11y/no-autofocus
Expand Down

0 comments on commit 2da7690

Please sign in to comment.