diff --git a/docs/6.x/docs/guides/migration.md b/docs/6.x/docs/guides/migration.md
index 0b0b13c650..36a83520ab 100644
--- a/docs/6.x/docs/guides/migration.md
+++ b/docs/6.x/docs/guides/migration.md
@@ -1883,7 +1883,13 @@ When selected, an icon set with `checkedIcon` uses `onPrimaryContainer`. If you
```tsx
import { Switch, useTheme } from 'react-native-paper';
-const TertiarySwitch = ({ value, onValueChange }) => {
+const TertiarySwitch = ({
+ value,
+ onValueChange,
+}: {
+ value: boolean;
+ onValueChange: (value: boolean) => void;
+}) => {
const theme = useTheme();
const switchTheme = {
colors: {
diff --git a/example/src/Examples/SwitchExample.tsx b/example/src/Examples/SwitchExample.tsx
index 09a3c7ec92..345c78be78 100644
--- a/example/src/Examples/SwitchExample.tsx
+++ b/example/src/Examples/SwitchExample.tsx
@@ -90,7 +90,7 @@ const SwitchExample = () => {
-
+
{
// Not the ring - it's real CSS on web now. This drives the
diff --git a/src/components/__tests__/Switch.test.tsx b/src/components/__tests__/Switch.test.tsx
index bdd378a556..00add3d464 100644
--- a/src/components/__tests__/Switch.test.tsx
+++ b/src/components/__tests__/Switch.test.tsx
@@ -312,7 +312,9 @@ describe('Switch operability', () => {
await render();
- expect(console.warn).not.toHaveBeenCalled();
+ expect(console.warn).not.toHaveBeenCalledWith(
+ expect.stringContaining('Switch:')
+ );
}
);
@@ -393,7 +395,7 @@ describe('Switch operability', () => {
await render();
expect(screen.getByRole('switch')).toBeDisabled();
- expect(screen.getByRole('switch')).not.toHaveProp('aria-readonly', true);
+ expect(screen.getByRole('switch')).not.toHaveProp('aria-readonly');
});
});
@@ -422,6 +424,13 @@ describe('Switch operability', () => {
expect(screen.getByRole('switch')).toBeEnabled();
});
+ it('does not expose aria-readonly on an operable switch on web', async () => {
+ jest.replaceProperty(Platform, 'OS', 'web');
+ await render( {}} />);
+
+ expect(screen.getByRole('switch')).not.toHaveProp('aria-readonly');
+ });
+
it('exposes a missing-handler fallback as read-only on web', async () => {
jest.replaceProperty(Platform, 'OS', 'web');
jest.spyOn(console, 'warn').mockImplementation(() => {});