From f485c03275c500d8faed7691920f04b273de28dc Mon Sep 17 00:00:00 2001 From: Anant Date: Wed, 7 Oct 2026 01:26:19 +0530 Subject: [PATCH 1/2] Stabilize passcode keypad labels and touch targets --- src/components/AppNumPad/KeyPadButton.tsx | 60 ++++++++++++----------- tests/components/KeyPadView.test.tsx | 38 ++++++++++++++ 2 files changed, 69 insertions(+), 29 deletions(-) create mode 100644 tests/components/KeyPadView.test.tsx diff --git a/src/components/AppNumPad/KeyPadButton.tsx b/src/components/AppNumPad/KeyPadButton.tsx index decf9e0b2..d34fa28d9 100644 --- a/src/components/AppNumPad/KeyPadButton.tsx +++ b/src/components/AppNumPad/KeyPadButton.tsx @@ -1,6 +1,5 @@ -import { StyleSheet, TouchableOpacity, Animated } from 'react-native'; +import { StyleSheet, TouchableOpacity, Animated, Text as NativeText } from 'react-native'; import React, { useState } from 'react'; -import Text from 'src/components/KeeperText'; import ScaleSpring from '../Animations/ScaleSpring'; import ThemedColor from '../ThemedColor/ThemedColor'; @@ -23,35 +22,38 @@ const KeyPadButton: React.FC = ({ title, onPressNumber, keyColor, bubbleE setPressed(false); }; - return ( - - onPressNumber(title)} - style={styles.keyPadElementTouchable} - testID={`key_${title}`} - > - {bubbleEffect && ( - - )} + const button = ( + onPressNumber(title)} + style={styles.keyPadElementTouchable} + testID={`key_${title}`} + accessibilityRole="button" + accessibilityLabel={title} + > + {bubbleEffect && ( + + )} - - {title} - - - + + {title} + + ); + + // The passcode keypad already has press feedback; keep its touch target outside a second gesture. + return bubbleEffect ? button : {button}; }; const styles = StyleSheet.create({ diff --git a/tests/components/KeyPadView.test.tsx b/tests/components/KeyPadView.test.tsx new file mode 100644 index 000000000..8e37e3e79 --- /dev/null +++ b/tests/components/KeyPadView.test.tsx @@ -0,0 +1,38 @@ +import React from 'react'; +import { fireEvent, render } from '@testing-library/react-native'; +import { View } from 'react-native'; +import KeyPadView from 'src/components/AppNumPad/KeyPadView'; + +jest.mock( + 'src/components/Animations/ScaleSpring', + () => + ({ children }: React.PropsWithChildren) => + children +); +jest.mock('src/components/ThemedColor/ThemedColor', () => jest.fn(() => '#ffffff')); + +describe('authentication keypad', () => { + it('renders all ten digits and delivers digit and delete taps', () => { + const onPressNumber = jest.fn(); + const onDeletePressed = jest.fn(); + const { getByText, getByTestId } = render( + } + /> + ); + + ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'].forEach((digit) => { + expect(getByText(digit)).toBeTruthy(); + }); + fireEvent.press(getByTestId('key_1')); + fireEvent.press(getByTestId('key_0')); + fireEvent.press(getByTestId('btn_clear')); + + expect(onPressNumber).toHaveBeenNthCalledWith(1, '1'); + expect(onPressNumber).toHaveBeenNthCalledWith(2, '0'); + expect(onDeletePressed).toHaveBeenCalledTimes(1); + }); +}); From 9dba85ba9568286d3883a135d8763578a6ce1dc2 Mon Sep 17 00:00:00 2001 From: Anant Date: Wed, 7 Oct 2026 18:56:16 +0530 Subject: [PATCH 2/2] Keep keypad rows native to prevent missing iOS digit targets --- src/components/AppNumPad/KeyPadView.tsx | 34 ++++++++++---------- tests/components/KeyPadView.test.tsx | 42 +++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 19 deletions(-) diff --git a/src/components/AppNumPad/KeyPadView.tsx b/src/components/AppNumPad/KeyPadView.tsx index efe8d6012..ac29ca4df 100644 --- a/src/components/AppNumPad/KeyPadView.tsx +++ b/src/components/AppNumPad/KeyPadView.tsx @@ -1,5 +1,5 @@ -import { Box, useColorMode } from '@gluestack-ui/themed-native-base'; -import { StyleSheet, TouchableOpacity } from 'react-native'; +import { useColorMode } from '@gluestack-ui/themed-native-base'; +import { StyleSheet, TouchableOpacity, View } from 'react-native'; import DeleteIcon from 'src/assets/images/deleteLight.svg'; import DeleteDarkIcon from 'src/assets/images/delete.svg'; import React from 'react'; @@ -28,9 +28,10 @@ const KeyPadView: React.FC = ({ }: Props) => { const { colorMode } = useColorMode(); + // Keep keypad rows native so digit targets mount consistently in the iOS renderer. return ( - - + + onPressNumber('1')} @@ -49,8 +50,8 @@ const KeyPadView: React.FC = ({ keyColor={keyColor} bubbleEffect={bubbleEffect} /> - - + + onPressNumber('4')} @@ -69,8 +70,8 @@ const KeyPadView: React.FC = ({ keyColor={keyColor} bubbleEffect={bubbleEffect} /> - - + + onPressNumber('7')} @@ -89,9 +90,9 @@ const KeyPadView: React.FC = ({ keyColor={keyColor} bubbleEffect={bubbleEffect} /> - - - + + + {enableDecimal ? ( onPressNumber('.')} @@ -104,11 +105,11 @@ const KeyPadView: React.FC = ({ ) : ( - + - + )} - + onPressNumber('0')} @@ -123,12 +124,13 @@ const KeyPadView: React.FC = ({ > {ClearIcon ? ClearIcon : colorMode === 'dark' ? : } - - + + ); }; const styles = StyleSheet.create({ + container: { marginTop: 'auto' }, keyPadElementTouchable: { flex: 1, height: hp('8%'), diff --git a/tests/components/KeyPadView.test.tsx b/tests/components/KeyPadView.test.tsx index 8e37e3e79..b65ae638f 100644 --- a/tests/components/KeyPadView.test.tsx +++ b/tests/components/KeyPadView.test.tsx @@ -26,13 +26,49 @@ describe('authentication keypad', () => { ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'].forEach((digit) => { expect(getByText(digit)).toBeTruthy(); + fireEvent.press(getByTestId(`key_${digit}`)); }); + fireEvent.press(getByTestId('btn_clear')); + + expect(onPressNumber.mock.calls.map(([digit]) => digit)).toEqual([ + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + '0', + ]); + expect(onDeletePressed).toHaveBeenCalledTimes(1); + }); + + it('preserves decimal amount entry and delete when passcode feedback is disabled', () => { + const onPressNumber = jest.fn(); + const onDeletePressed = jest.fn(); + const { getByTestId, queryByTestId, rerender } = render( + } + /> + ); fireEvent.press(getByTestId('key_1')); + fireEvent.press(getByTestId('btn-decimal')); fireEvent.press(getByTestId('key_0')); fireEvent.press(getByTestId('btn_clear')); - - expect(onPressNumber).toHaveBeenNthCalledWith(1, '1'); - expect(onPressNumber).toHaveBeenNthCalledWith(2, '0'); + expect(onPressNumber.mock.calls.map(([value]) => value)).toEqual(['1', '.', '0']); expect(onDeletePressed).toHaveBeenCalledTimes(1); + rerender( + } + /> + ); + expect(queryByTestId('btn-decimal')).toBeNull(); }); });