-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: UIKit buttons not responding on some Android devices #7573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,104
−682
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a4b80b2
using a seperate button component for ui-kit button
Rohit3523 ba988d0
Added use no memo in Actions
Rohit3523 472b096
Merge branch 'develop' into fix/uikit-button-conflict
Rohit3523 8e9bd2e
added story and unit test
Rohit3523 60928a7
added maestro test for button
Rohit3523 0bf7633
using test-14 instead of 15
Rohit3523 5853d20
Merge branch 'develop' into fix/uikit-button-conflict
Rohit3523 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| appId: ${APP_ID} | ||
| name: UIKit Button Kit | ||
| onFlowStart: | ||
| - runFlow: '../../helpers/setup.yaml' | ||
| onFlowComplete: | ||
| - evalScript: ${output.utils.deleteCreatedUsers()} | ||
| tags: | ||
| - test-14 | ||
|
|
||
| --- | ||
| - evalScript: ${output.user = output.utils.createUser()} | ||
| - evalScript: ${output.room = output.utils.createRandomRoom(output.user.username, output.user.password)} | ||
|
|
||
| - runFlow: | ||
| file: '../../helpers/login-with-deeplink.yaml' | ||
| env: | ||
| USERNAME: ${output.user.username} | ||
| PASSWORD: ${output.user.password} | ||
|
|
||
| - runFlow: | ||
| file: '../../helpers/navigate-to-room.yaml' | ||
| env: | ||
| ROOM: ${output.room.name} | ||
|
|
||
| # here send /uikit-test command | ||
| - tapOn: | ||
| id: message-composer-input | ||
| - inputText: | ||
| text: '/uikit-test' | ||
| - extendedWaitUntil: | ||
| visible: | ||
| id: autocomplete-item-uikit-test | ||
| timeout: 10000 | ||
| - tapOn: | ||
| id: autocomplete-item-uikit-test | ||
| - tapOn: | ||
| id: 'message-composer-send' | ||
| - tapOn: Tap Me | ||
| - extendedWaitUntil: | ||
| visible: | ||
| text: '.*Button tap received! This reply is private to you*.' | ||
| timeout: 10000 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import UIKitButton from './Button'; | ||
|
|
||
| const buttonProps = { | ||
| title: 'Press me!', | ||
| type: 'primary' as const, | ||
| onPress: () => {} | ||
| }; | ||
|
|
||
| export default { | ||
| title: 'UIKit/Button', | ||
| component: UIKitButton | ||
| }; | ||
|
|
||
| export const PrimaryButton = () => <UIKitButton {...buttonProps} />; | ||
|
|
||
| export const SecondaryButton = () => <UIKitButton {...buttonProps} type='secondary' />; | ||
|
|
||
| export const LoadingButton = () => <UIKitButton loading {...buttonProps} />; | ||
|
|
||
| export const CustomStyleButton = () => <UIKitButton {...buttonProps} style={{ marginTop: 16 }} />; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { fireEvent, render } from '@testing-library/react-native'; | ||
|
|
||
| import UIKitButton from './Button'; | ||
| import * as stories from './Button.stories'; | ||
| import { generateSnapshots } from '../../../.rnstorybook/generateSnapshots'; | ||
|
|
||
| const onPressMock = jest.fn(); | ||
|
|
||
| const testProps = { | ||
| title: 'Press me!', | ||
| onPress: onPressMock | ||
| }; | ||
|
|
||
| describe('UIKitButtonTests', () => { | ||
| beforeEach(() => { | ||
| onPressMock.mockClear(); | ||
| }); | ||
|
|
||
| test('rendered with correct title', async () => { | ||
| const { findByText } = render(<UIKitButton {...testProps} />); | ||
| const buttonTitle = await findByText(testProps.title); | ||
| expect(buttonTitle).toBeTruthy(); | ||
| expect(buttonTitle.props.children).toEqual(testProps.title); | ||
| }); | ||
|
|
||
| test('find button using accessibilityLabel', () => { | ||
| const { getByLabelText } = render(<UIKitButton {...testProps} />); | ||
| const button = getByLabelText(testProps.title); | ||
| expect(button).toBeTruthy(); | ||
| }); | ||
|
|
||
| test('renders secondary variant with the same title', async () => { | ||
| const { findByText } = render(<UIKitButton {...testProps} type='secondary' />); | ||
| const buttonTitle = await findByText(testProps.title); | ||
| expect(buttonTitle).toBeTruthy(); | ||
| }); | ||
|
|
||
| test('title not visible while loading', () => { | ||
| const { queryByText } = render(<UIKitButton {...testProps} loading />); | ||
| const buttonTitle = queryByText(testProps.title); | ||
| expect(buttonTitle).toBeNull(); | ||
| }); | ||
|
|
||
| test('onPress is not triggered while loading', () => { | ||
| const { getByLabelText } = render(<UIKitButton {...testProps} loading />); | ||
| const button = getByLabelText(testProps.title); | ||
| fireEvent.press(button); | ||
| expect(onPressMock).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| test('should trigger onPress function on button press', () => { | ||
| const { getByLabelText } = render(<UIKitButton {...testProps} />); | ||
| const button = getByLabelText(testProps.title); | ||
| fireEvent.press(button); | ||
| expect(onPressMock).toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
|
|
||
| generateSnapshots(stories); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { type FC } from 'react'; | ||
| import { Pressable, StyleSheet, Text, type StyleProp, type ViewStyle } from 'react-native'; | ||
|
|
||
| import { useTheme } from '../../theme'; | ||
| import sharedStyles from '../../views/Styles'; | ||
| import ActivityIndicator from '../ActivityIndicator'; | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { | ||
| borderRadius: 4, | ||
| paddingVertical: 14, | ||
| paddingHorizontal: 16, | ||
| justifyContent: 'center' | ||
| }, | ||
| text: { | ||
| ...sharedStyles.textMedium, | ||
| ...sharedStyles.textAlignCenter | ||
| }, | ||
| pressed: { | ||
| opacity: 0.7 | ||
| } | ||
| }); | ||
|
|
||
| interface IUIKitButtonProps { | ||
| title: string; | ||
| onPress: () => void; | ||
| type?: 'primary' | 'secondary'; | ||
| loading?: boolean; | ||
| style?: StyleProp<ViewStyle>; | ||
| } | ||
|
|
||
| const UIKitButton: FC<IUIKitButtonProps> = ({ title, onPress, type = 'primary', loading, style }) => { | ||
| const { colors } = useTheme(); | ||
| const isPrimary = type === 'primary'; | ||
| const backgroundColor = isPrimary ? colors.buttonBackgroundPrimaryDefault : colors.buttonBackgroundSecondaryDefault; | ||
| const color = isPrimary ? colors.fontWhite : colors.fontDefault; | ||
|
|
||
| return ( | ||
| <Pressable | ||
| onPress={onPress} | ||
| disabled={loading} | ||
| accessibilityLabel={title} | ||
| accessibilityRole='button' | ||
| style={({ pressed }) => [styles.container, { backgroundColor }, style, pressed && styles.pressed]}> | ||
| {loading ? <ActivityIndicator color={color} style={{ padding: 0 }} /> : <Text style={[styles.text, { color }]}>{title}</Text>} | ||
| </Pressable> | ||
| ); | ||
| }; | ||
|
|
||
| export default UIKitButton; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.