Skip to content

Commit 9873283

Browse files
fix(components): Divider accessibility defaults can't be overridden (#224)
## Summary - `Divider.tsx` spread `{...rest}` after its `accessible={false}` / `importantForAccessibility="no"` defaults, so a caller passing either prop explicitly could override Divider's "hidden from assistive technology" behavior. - Reordered so the component's own defaults always win, since Divider is purely decorative and no legitimate use case was found for making it independently accessible/focusable — same reasoning as the `disabled` merge fix in #221 for Button/IconButton/Input/TextArea. - Added a regression test asserting `accessible`/`importantForAccessibility` can't be overridden via props. Fixes #219 ## Test plan - [x] `pnpm jest Divider` — 4/4 pass - [x] `pnpm lint` — clean - [x] `pnpm check-types` — clean - [x] `pnpm prettier --check` — clean
1 parent b2fa65c commit 9873283

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

packages/components/src/components/Divider/Divider.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,17 @@ describe("Divider", () => {
2121
marginVertical: 8,
2222
});
2323
});
24+
25+
it("cannot be made accessible by a caller-supplied prop", () => {
26+
render(
27+
<Divider
28+
testID="divider"
29+
accessible={true}
30+
importantForAccessibility="yes"
31+
/>
32+
);
33+
const divider = screen.getByTestId("divider");
34+
expect(divider).toHaveProp("accessible", false);
35+
expect(divider).toHaveProp("importantForAccessibility", "no");
36+
});
2437
});

packages/components/src/components/Divider/Divider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export const Divider = ({ style, ...rest }: DividerProps) => {
1010
return (
1111
<View
1212
style={[styles.divider, style]}
13+
{...rest}
1314
accessible={false}
1415
importantForAccessibility="no"
15-
{...rest}
1616
/>
1717
);
1818
};

0 commit comments

Comments
 (0)