fix: button links not responding when touched on a mobile device (#217)

This commit is contained in:
kimatata
2025-04-29 18:38:09 +09:00
committed by GitHub
parent 921c732860
commit de9e26a241
6 changed files with 72 additions and 54 deletions

View File

@@ -0,0 +1,10 @@
'use client';
import { forwardRef } from 'react';
import { Link } from '@/src/i18n/routing';
type Props = React.ComponentPropsWithoutRef<typeof Link>;
const ClientLink = forwardRef<HTMLAnchorElement, Props>(({ href, ...props }, ref) => (
<Link ref={ref} href={href} {...props} />
));
ClientLink.displayName = 'ClientLink';
export default ClientLink;

View File

@@ -101,12 +101,7 @@ export default function HeaderNavbarMenu({ messages, locale }: Props) {
{commonLinks.map((link) => {commonLinks.map((link) =>
link.isExternal ? ( link.isExternal ? (
<NavbarItem key={link.uid} className="hidden md:block"> <NavbarItem key={link.uid} className="hidden md:block">
<NextUiLink <NextUiLink isExternal href={link.href} showAnchorIcon>
isExternal
href={link.href}
showAnchorIcon
anchorIcon={<MoveUpRight size={12} className="ms-1" />}
>
{link.label} {link.label}
</NextUiLink> </NextUiLink>
</NavbarItem> </NavbarItem>

View File

@@ -1,9 +1,9 @@
import { title, subtitle } from '@/components/primitives';
import { Button, Link as NextUiLink } from '@heroui/react'; import { Button, Link as NextUiLink } from '@heroui/react';
import { MoveUpRight } from 'lucide-react'; import { MoveUpRight } from 'lucide-react';
import { Link } from '@/src/i18n/routing';
import { useTranslations } from 'next-intl'; import { useTranslations } from 'next-intl';
import { title, subtitle } from '@/components/primitives';
import { LocaleCodeType } from '@/types/locale'; import { LocaleCodeType } from '@/types/locale';
import ClientLink from '@/components/ClientLink';
type Props = { type Props = {
locale: LocaleCodeType; locale: LocaleCodeType;
@@ -34,35 +34,37 @@ export default function MainTitle({ locale }: Props) {
<h4 className={subtitle({ class: 'mt-4' })}>{t('integrate_and_manage')}</h4> <h4 className={subtitle({ class: 'mt-4' })}>{t('integrate_and_manage')}</h4>
<div className="mt-5"> <div className="mt-5">
<Link href={`/projects/`} locale={locale}> <Button as={ClientLink} href={`/projects/`} locale={locale} color="primary" radius="full" className="px-0">
<Button color="primary" radius="full" className="px-0">
{t('demo')} {t('demo')}
</Button> </Button>
</Link>
<NextUiLink isExternal href="https://kimatata.github.io/unittcms/docs/getstarted/selfhost" aria-label="docs">
<Button <Button
showAnchorIcon
as={NextUiLink}
isExternal
href="https://kimatata.github.io/unittcms/docs/getstarted/selfhost"
aria-label="docs"
color="primary" color="primary"
variant="bordered" variant="bordered"
radius="full" radius="full"
className="ms-2" className="ms-2"
endContent={<MoveUpRight size={12} />}
> >
{t('get_started')} {t('get_started')}
</Button> </Button>
</NextUiLink>
<NextUiLink size="sm" isExternal href="https://github.com/kimatata/unittcms" aria-label="Github">
<Button <Button
showAnchorIcon
as={NextUiLink}
isExternal
href="https://github.com/kimatata/unittcms"
aria-label="Github"
color="primary" color="primary"
variant="bordered" variant="bordered"
radius="full" radius="full"
className="ms-2" className="ms-2"
endContent={<MoveUpRight size={12} />}
> >
GitHub GitHub
</Button> </Button>
</NextUiLink>
</div> </div>
</div> </div>
); );

View File

@@ -86,11 +86,16 @@ export default function AccountPage({ messages, locale }: Props) {
) : ( ) : (
<> <>
<span className="text-default-500 me-2">{messages.notOwnAnyProjects}</span> <span className="text-default-500 me-2">{messages.notOwnAnyProjects}</span>
<Link href={`/projects/`} locale={locale} className={NextUiLinkClasses}> <Button
<Button variant="flat" size="sm" endContent={<ArrowRight size={12} />}> as={Link}
href={`/projects/`}
locale={locale}
variant="flat"
size="sm"
endContent={<ArrowRight size={12} />}
>
{messages.findProjects} {messages.findProjects}
</Button> </Button>
</Link>
</> </>
)} )}
</div> </div>

View File

@@ -97,11 +97,16 @@ export default function AuthPage({ isSignup, messages, locale }: Props) {
<Card className="w-[480px] mt-16"> <Card className="w-[480px] mt-16">
<CardHeader className="px-4 pt-4 pb-0 flex justify-between"> <CardHeader className="px-4 pt-4 pb-0 flex justify-between">
<h4 className="font-bold text-large">{messages.title}</h4> <h4 className="font-bold text-large">{messages.title}</h4>
<Link href={isSignup ? '/account/signin' : '/account/signup'} locale={locale}> <Button
<Button color="primary" variant="light" endContent={<ChevronRight size={16} />}> as={Link}
href={isSignup ? '/account/signin' : '/account/signup'}
locale={locale}
color="primary"
variant="light"
endContent={<ChevronRight size={16} />}
>
{messages.linkTitle} {messages.linkTitle}
</Button> </Button>
</Link>
</CardHeader> </CardHeader>
<CardBody className="overflow-visible px-4 pt-0 pb-4"> <CardBody className="overflow-visible px-4 pt-0 pb-4">
<form> <form>

View File

@@ -14,8 +14,8 @@ import {
Selection, Selection,
SortDescriptor, SortDescriptor,
} from '@heroui/react'; } from '@heroui/react';
import { Link, NextUiLinkClasses } from '@/src/i18n/routing';
import { Plus, MoreVertical, Trash } from 'lucide-react'; import { Plus, MoreVertical, Trash } from 'lucide-react';
import { Link } from '@/src/i18n/routing';
import { CaseType, CasesMessages } from '@/types/case'; import { CaseType, CasesMessages } from '@/types/case';
import { PriorityMessages } from '@/types/priority'; import { PriorityMessages } from '@/types/priority';
import TestCasePriority from '@/components/TestCasePriority'; import TestCasePriority from '@/components/TestCasePriority';
@@ -82,14 +82,15 @@ export default function TestCaseTable({
return <span>{cellValue as number}</span>; return <span>{cellValue as number}</span>;
case 'title': case 'title':
return ( return (
<Button size="sm" variant="light" className="data-[hover=true]:bg-transparent"> <Button
<Link size="sm"
as={Link}
href={`/projects/${projectId}/folders/${testCase.folderId}/cases/${testCase.id}`} href={`/projects/${projectId}/folders/${testCase.folderId}/cases/${testCase.id}`}
locale={locale} locale={locale}
className={NextUiLinkClasses} variant="light"
className="data-[hover=true]:bg-transparent"
> >
{cellValue as string} {cellValue as string}
</Link>
</Button> </Button>
); );
case 'priority': case 'priority':