Skip to content

Commit 51517ad

Browse files
thinkclayclaude
andauthored
fix(a11y): stop passing importantForAccessibility to the DOM (#50)
FocusGuard renders only on web and set `importantForAccessibility="no"`, which react-native-web has no mapping for — it reached the DOM and React warned on every page that mounted a guard. `accessible={false}` already says what the prop meant. BarChart's Svg carried the same prop on both platforms; on web it is `aria-hidden` now, the labelled wrapper above it carrying the chart's meaning either way. Refs Scaffald/SaaS#993 Co-authored-by: Claude Fable 5.1 <[email protected]>
1 parent 965f605 commit 51517ad

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎src/accessibility/FocusGuard.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ export const FocusGuard = forwardRef<View, FocusGuardProps>(
6060
// Web-specific prop for tab navigation
6161
{...(Platform.OS === 'web' && { tabIndex: 0 })}
6262
onFocus={handleFocus}
63+
// `accessible={false}` is the whole of it on web: react-native-web has
64+
// no mapping for `importantForAccessibility`, so it reached the DOM and
65+
// React warned on every page that mounted a guard (Scaffald/SaaS#993).
6366
accessible={false}
64-
importantForAccessibility="no"
6567
{...props}
6668
/>
6769
)

‎src/components/Chart/BarChart.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* ```
1313
*/
1414

15-
import { View } from 'react-native'
15+
import { Platform, View } from 'react-native'
1616
import Svg, { Rect } from 'react-native-svg'
1717
import type { BarChartProps } from './Chart.types'
1818
import { normalizeData, getBarChartColors } from './Chart.utils'
@@ -99,7 +99,11 @@ export function BarChart({
9999
height={height}
100100
viewBox={`0 0 ${width} ${height}`}
101101
accessible={false}
102-
importantForAccessibility="no-hide-descendants"
102+
// The native prop has no web mapping and would reach the DOM; the
103+
// labelled wrapper above carries the chart's meaning on both.
104+
{...(Platform.OS === 'web'
105+
? { 'aria-hidden': true }
106+
: { importantForAccessibility: 'no-hide-descendants' as const })}
103107
>
104108
{normalizedData.map((value, index) => {
105109
const x = gap + index * (barWidth + gap)

0 commit comments

Comments
 (0)