diff --git a/src/blocks/Header/Header.tsx b/src/blocks/Header/Header.tsx index 166a3fa80..ca2c89b99 100644 --- a/src/blocks/Header/Header.tsx +++ b/src/blocks/Header/Header.tsx @@ -1,6 +1,6 @@ import React, {useContext} from 'react'; -import {Button, HTML, Media, RouterLink} from '../../components'; +import {Button, HTML, Media} from '../../components'; import HeaderBreadcrumbs from '../../components/HeaderBreadcrumbs/HeaderBreadcrumbs'; import {getMediaImage} from '../../components/Media/Image/utils'; import YFMWrapper from '../../components/YFMWrapper/YFMWrapper'; @@ -141,14 +141,12 @@ export const HeaderBlock = (props: WithChildren) => {
{buttons && buttons.map((button, index) => ( - -
)} diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 559ab1adf..7ceb00dbe 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -3,6 +3,7 @@ import React, {useCallback, useContext} from 'react'; import {Button as CommonButton, Icon, Platform, StoreBadge} from '@gravity-ui/uikit'; import {LocaleContext} from '../../context/localeContext/localeContext'; +import {LocationContext} from '../../context/locationContext'; import {useAnalytics} from '../../hooks'; import {useMetrika} from '../../hooks/useMetrika'; import {Github} from '../../icons'; @@ -25,6 +26,7 @@ const b = block('button-block'); const Button = (props: ButtonProps) => { const handleMetrika = useMetrika(); + const {Link} = useContext(LocationContext); const {lang, tld} = useContext(LocaleContext); const { className, @@ -95,6 +97,7 @@ const Button = (props: ButtonProps) => { size={toCommonSize(size as OldButtonSize)} href={url ? setUrlTld(url, tld) : undefined} width={width} + component={Link} {...buttonProps} > {icon && buttonImg.position === 'left' ? icon : null} diff --git a/src/components/RouterLink/RouterLink.tsx b/src/components/RouterLink/RouterLink.tsx index 48f5a99b4..b0359ae2b 100644 --- a/src/components/RouterLink/RouterLink.tsx +++ b/src/components/RouterLink/RouterLink.tsx @@ -22,12 +22,12 @@ const RouterLink = ({ }: WithChildren) => { const {Link} = useContext(LocationContext); - const isExternal = href.startsWith('http://') || href.startsWith('https://'); + const isExternal = href?.startsWith('http://') || href?.startsWith('https://'); const shouldAnchorTag = typeof href === 'string' && (!Link || isExternal || forceAnchor); const component = shouldAnchorTag ? 'a' : Link; if (!component) { - return null; + return
{JSON.stringify({isExternal, shouldAnchorTag, component})}
; } const linkProps = { @@ -41,7 +41,8 @@ const RouterLink = ({ { href, ...(shouldAnchorTag ? linkProps : {}), - commonProps, + ...commonProps, + area: shouldAnchorTag ? '1' : '2', }, children, ); diff --git a/src/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.tsx b/src/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.tsx index e5ec3f9b5..5a500e41c 100644 --- a/src/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.tsx +++ b/src/navigation/components/NavigationItem/components/NavigationButton/NavigationButton.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import {Button, RouterLink} from '../../../../../components'; +import {Button} from '../../../../../components'; import {BlockIdContext} from '../../../../../context/blockIdContext'; import {ButtonProps} from '../../../../../models'; import {block} from '../../../../../utils'; @@ -15,17 +15,11 @@ const ANALYTICS_ID = 'navigation'; type NavigationButtonProps = Pick & ButtonProps; export const NavigationButton: React.FC = (props) => { - const {url, target, className} = props; + const {url, className} = props; const classes = b(null, className); return ( - {target ? ( -