Skip to content

Commit

Permalink
fix: sonar cloud issue
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnsonMao committed Nov 2, 2024
1 parent ed44add commit 00fa281
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion components/shared/Carousel/v2/CarouselMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { cn } from "@/lib/utils";
import { useCarousel } from "./CarouselContext";
import { CarouselMainProps } from "./Carousel.type";

export default function CarouselMain({ className }: CarouselMainProps) {
export default function CarouselMain({
className,
}: Readonly<CarouselMainProps>) {
const { showIndex, items, Component, renderKey } = useCarousel();
const [carouselItemWidth, setCarouselItemWidth] = useState(0);
const carouselRef = useRef<HTMLDivElement>(null);
Expand Down
2 changes: 1 addition & 1 deletion components/shared/Carousel/v2/CarouselPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CarouselActionType, CarouselPaginationProps } from "./Carousel.type";

export default function CarouselPagination({
className,
}: CarouselPaginationProps) {
}: Readonly<CarouselPaginationProps>) {
const { showIndex, items, renderKey } = useCarousel();
const dispatch = useCarouselDispatch();

Expand Down
1 change: 0 additions & 1 deletion components/shared/InputOTP/inputOTP.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Meta, StoryObj } from "@storybook/react";
import { useArgs } from "@storybook/preview-api";

import InputOTP from ".";

Expand Down
12 changes: 10 additions & 2 deletions components/shared/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, {
useEffect,
ForwardRefRenderFunction,
forwardRef,
KeyboardEventHandler,
} from "react";
import { cn } from "@/lib/utils";
import Portal from "../Portal/Portal";
Expand Down Expand Up @@ -52,6 +53,12 @@ const InternalModal: ForwardRefRenderFunction<HTMLDivElement, ModalProps> = (

const [removeDOM, setRemoveDOM] = useState(!isOpen);

const handleKeyUp: KeyboardEventHandler = (e) => {
if (maskClosable && e.key === "Enter") {
onClose?.();
}
};

useEffect(() => {
let timer: NodeJS.Timeout;

Expand Down Expand Up @@ -80,15 +87,16 @@ const InternalModal: ForwardRefRenderFunction<HTMLDivElement, ModalProps> = (
isOpen ? "opacity-100" : "opacity-0"
)}
data-testid="modal-mask"
tabIndex={maskClosable ? 0 : -1}
onClick={maskClosable ? onClose : undefined}
onKeyUp={handleKeyUp}
/>
<div
className={cn(
"fixed z-20 left-1/2 -translate-x-1/2 duration-200",
containerSizeMap[size],
isOpen ? "opacity-100" : "opacity-0"
)}
data-testid="modal-container"
>
<BoxFancy
ref={ref}
Expand All @@ -98,7 +106,7 @@ const InternalModal: ForwardRefRenderFunction<HTMLDivElement, ModalProps> = (
dialogSize[size]
)}
{...restProps}
role="dialog"
role="alertdialog"
>
<header className="text-[22px] text-center">{title}</header>
<div>{children}</div>
Expand Down
2 changes: 1 addition & 1 deletion components/shared/SelectBoxGroup/SelectBoxGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function SelectBoxGroup<T = string>({
itemClassName,
itemWrapperClassName,
onChange,
}: SelectBoxGroupProps<T>) {
}: Readonly<SelectBoxGroupProps<T>>) {
const reactId = useId();
const selectBoxId = `select_box_${reactId}`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import useRequest from "@/hooks/useRequest";
import { useRouter } from "next/router";
import { useToast } from "@/components/shared/Toast";
import useUser from "@/hooks/useUser";
import { CarouselItemProps } from "@/components/shared/Carousel/v2";
import { GameType } from "@/requests/games";
import { fastJoinGameEndpoint } from "@/requests/rooms";
import Icon from "@/components/shared/Icon";
Expand Down

0 comments on commit 00fa281

Please sign in to comment.