Skip to content

Commit e5c9281

Browse files
committed
fix: Link to should be allowed to have tooltip
1 parent cd59627 commit e5c9281

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/rules/__tests__/a11y-tooltip-interactive-trigger.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ ruleTester.run('non-interactive-tooltip-trigger', rule, {
6767
</Link>
6868
</Tooltip>
6969
`,
70+
`
71+
import {Tooltip, Link} from '@primer/react';
72+
<Tooltip aria-label="product" direction="e">
73+
<Link to={productLink}>
74+
Product
75+
</Link>
76+
</Tooltip>
77+
`,
78+
`
79+
import {Tooltip, Link} from '@primer/react';
80+
<Tooltip aria-label="product" direction="e">
81+
<Link to="https://github.com">
82+
Product
83+
</Link>
84+
</Tooltip>
85+
`,
7086
],
7187
invalid: [
7288
{

src/rules/a11y-tooltip-interactive-trigger.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ const isJSXValue = attributes => {
3131

3232
const isInteractiveAnchor = child => {
3333
const hasHref = getJSXOpeningElementAttribute(child.openingElement, 'href')
34-
if (!hasHref) return false
35-
const href = getJSXOpeningElementAttribute(child.openingElement, 'href').value.value
34+
const hasTo = getJSXOpeningElementAttribute(child.openingElement, 'to')
35+
if (!hasHref && !hasTo) return false
36+
37+
const href = hasHref ? getJSXOpeningElementAttribute(child.openingElement, 'href').value.value : getJSXOpeningElementAttribute(child.openingElement, 'to').value.value
38+
3639
const hasJSXValue = isJSXValue(child.openingElement.attributes)
3740
const isAnchorInteractive = (typeof href === 'string' && href !== '') || hasJSXValue
3841

0 commit comments

Comments
 (0)