Skip to content

Commit 82bec90

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(design): retain unresolved links from spread props
1 parent f4252c9 commit 82bec90

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎scripts/design-conformance/control-inventory.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,8 @@ export function inspectControls(
14231423
}
14241424
const native = use.target.startsWith('native:')
14251425
const nativeKind = native ? nativeRole(use.target.slice(7), use.inputs) : undefined
1426+
const unresolvedAnchor =
1427+
native && use.tag === 'a' && proof.unknown.has('Anchor href remains unresolved')
14261428
const candidate =
14271429
!!nativeKind ||
14281430
(proof.relationships.has('polymorphic-renderer') && proof.unknown.size > 0) ||
@@ -1432,7 +1434,7 @@ export function inspectControls(
14321434
/^on(?:click|doubleclick|pointerdown|mousedown|keydown|keyup)$/i.test(h)
14331435
) ||
14341436
(native && use.tag === 'input' && !!use.inputs.type?.unresolved) ||
1435-
(native && use.tag === 'a' && !!use.inputs.href?.unresolved) ||
1437+
unresolvedAnchor ||
14361438
!!use.inputs.role?.unresolved ||
14371439
!!use.inputs.tabIndex?.unresolved ||
14381440
!!use.inputs.tabIndex?.values?.some((v) => Number(v) >= 0)
@@ -1455,7 +1457,7 @@ export function inspectControls(
14551457
(!native && proof.unknown.size > 0) ||
14561458
!!use.inputs.role?.unresolved ||
14571459
(native && use.tag === 'input' && !!use.inputs.type?.unresolved) ||
1458-
(native && use.tag === 'a' && !!use.inputs.href?.unresolved)
1460+
unresolvedAnchor
14591461
const origin: ControlRecord['origin'] = use.hidden
14601462
? 'nonvisual'
14611463
: central

‎scripts/design-scan/controls.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,18 @@ test('imperative anchors require href or an explicit interaction', () => {
552552
})
553553
expect(consumer(f.scan()).map((r) => r.inputs.href?.values)).toEqual([['/go']])
554554
})
555+
test('spread anchor href remains unresolved without inventing interaction for an omitted href', () => {
556+
const f = fixture({
557+
[location]:
558+
"export const A=props=><><a {...props} className='rounded-lg'>Unknown</a><a {...props} href={undefined}>Text</a><a {...{href:'/go'}} className='rounded-lg'>Known</a></>",
559+
})
560+
const result = f.scan()
561+
const records = consumer(result)
562+
expect(records).toHaveLength(2)
563+
expect(records.map((r) => r.origin)).toEqual(['unresolved', 'local-control'])
564+
expect(records[0].inputs.className.values).toEqual(['rounded-lg'])
565+
expect(result.unchecked.some((d) => d.reason === 'Anchor href remains unresolved')).toBe(true)
566+
})
555567
test('DOM class and uppercase attributes normalize before control review', () => {
556568
const f = fixture({
557569
[location]:

0 commit comments

Comments
 (0)