Skip to content

Commit

Permalink
Fix submit button (#88)
Browse files Browse the repository at this point in the history
* fix: missing Pressable for Form.Submit

* fix: missing Pressable for Form.Submit
  • Loading branch information
ceceppa authored Mar 29, 2023
1 parent c0e4f5c commit e8b4d96
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions lib/components/FormSubmit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,28 @@ export type FormSubmitProps = React.PropsWithChildren<{
}>;

export const FormSubmit = (props: FormSubmitProps) => {
const { submitForm } = useForm();
const { isScreenReaderEnabled } = useAMAContext();

return isScreenReaderEnabled ? (
<FormSubmitForScreenReader {...props} />
) : (
<>{props.children}</>
return (
<Pressable accessibilityRole="button" {...props} onPress={submitForm}>
{isScreenReaderEnabled ? (
<FormSubmitForScreenReader {...props} />
) : (
props.children
)}
</Pressable>
);
};

const FormSubmitForScreenReader = ({ children, ...rest }: FormSubmitProps) => {
const { submitForm } = useForm();

const FormSubmitForScreenReader = ({
children,
}: React.PropsWithChildren<{}>) => {
return (
<Pressable accessibilityRole="button" {...rest} onPress={submitForm}>
<View pointerEvents="none">
<HideChildrenFromAccessibilityTree>
{children}
</HideChildrenFromAccessibilityTree>
</View>
</Pressable>
<View pointerEvents="none">
<HideChildrenFromAccessibilityTree>
{children}
</HideChildrenFromAccessibilityTree>
</View>
);
};

0 comments on commit e8b4d96

Please sign in to comment.