diff --git a/src/components/Inputs/Button.tsx b/src/components/Inputs/Button.tsx index 303ec84..b9f23c3 100644 --- a/src/components/Inputs/Button.tsx +++ b/src/components/Inputs/Button.tsx @@ -21,6 +21,7 @@ interface Props { text?: string | null | undefined; alwaysNewTab?: boolean; onClick?: MouseEventHandler; + onMouseUp?: MouseEventHandler; draggable?: boolean; badgeNumber?: number; disabled?: boolean; @@ -33,6 +34,7 @@ export const Button = ({ draggable, id, onClick, + onMouseUp, active, className, icon, @@ -52,6 +54,7 @@ export const Button = ({ draggable={draggable} id={id} onClick={onClick} + onMouseUp={onMouseUp} onFocus={(event) => event.target.blur()} className={cJoin( `group grid cursor-pointer select-none grid-flow-col place-content-center diff --git a/src/components/Library/PreviewCardCTAs.tsx b/src/components/Library/PreviewCardCTAs.tsx index 7ce0a3b..8ea1ae0 100644 --- a/src/components/Library/PreviewCardCTAs.tsx +++ b/src/components/Library/PreviewCardCTAs.tsx @@ -30,8 +30,8 @@ export const PreviewCardCTAs = ({ id, expand = false }: Props): JSX.Element => { icon={Icon.Favorite} text={expand ? langui.want_it : undefined} active={libraryItemUserStatus[id] === LibraryItemUserStatus.Want} - onClick={(event) => { - event.preventDefault(); + onMouseUp={(event) => event.stopPropagation()} + onClick={() => { setLibraryItemUserStatus((current) => { const newLibraryItemUserStatus = { ...current }; newLibraryItemUserStatus[id] = @@ -48,8 +48,8 @@ export const PreviewCardCTAs = ({ id, expand = false }: Props): JSX.Element => { icon={Icon.BackHand} text={expand ? langui.have_it : undefined} active={libraryItemUserStatus[id] === LibraryItemUserStatus.Have} - onClick={(event) => { - event.preventDefault(); + onMouseUp={(event) => event.stopPropagation()} + onClick={() => { setLibraryItemUserStatus((current) => { const newLibraryItemUserStatus = { ...current }; newLibraryItemUserStatus[id] = diff --git a/src/pages/contents/[slug].tsx b/src/pages/contents/[slug].tsx index c22be0f..8403cfb 100644 --- a/src/pages/contents/[slug].tsx +++ b/src/pages/contents/[slug].tsx @@ -458,11 +458,9 @@ export const getStaticProps: GetStaticProps = async (context) => { const thumbnail = content.contents.data[0].attributes.thumbnail?.data?.attributes; - if (content.contents.data[0].attributes.folder?.data?.attributes?.contents?.data) { - content.contents.data[0].attributes.folder.data.attributes.contents.data.sort((a, b) => - a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0 - ); - } + content.contents.data[0].attributes.folder?.data?.attributes?.contents?.data.sort((a, b) => + a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0 + ); const props: Props = { content: content.contents.data[0].attributes as ContentWithTranslations, diff --git a/src/pages/contents/all.tsx b/src/pages/contents/all.tsx index 24218ed..2d8d3a0 100644 --- a/src/pages/contents/all.tsx +++ b/src/pages/contents/all.tsx @@ -298,6 +298,7 @@ export const getStaticProps: GetStaticProps = async (context) => { language_code: context.locale ?? "en", }); if (!contents.contents) return { notFound: true }; + contents.contents.data.sort((a, b) => { const titleA = a.attributes?.slug ?? ""; const titleB = b.attributes?.slug ?? ""; diff --git a/src/pages/contents/folder/[slug].tsx b/src/pages/contents/folder/[slug].tsx index 02719a9..7dbf261 100644 --- a/src/pages/contents/folder/[slug].tsx +++ b/src/pages/contents/folder/[slug].tsx @@ -215,22 +215,13 @@ export const getStaticProps: GetStaticProps = async (context) => { const folder = contentsFolder.contentsFolders.data[0].attributes; - const subFolders = { - // eslint-disable-next-line id-denylist - data: filterHasAttributes(folder.subfolders?.data, ["attributes.slug"]).sort((a, b) => - naturalCompare(a.attributes.slug, b.attributes.slug) - ), - }; + folder.subfolders?.data.sort((a, b) => + a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0 + ); - const contents = { - // eslint-disable-next-line id-denylist - data: filterHasAttributes(folder.contents?.data, ["attributes.slug"]).sort((a, b) => - naturalCompare(a.attributes.slug, b.attributes.slug) - ), - }; - - folder.contents = contents; - folder.subfolders = subFolders; + folder.contents?.data.sort((a, b) => + a.attributes && b.attributes ? naturalCompare(a.attributes.slug, b.attributes.slug) : 0 + ); const title = (() => { if (slug === "root") {