Skip to content

Commit e45b714

Browse files
committed
fix: focus on thread and reactions
1 parent 0907cc1 commit e45b714

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

app/containers/message/Reactions.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ const AddReaction = React.memo(({ theme }: { theme: TSupportedThemes }) => {
3939
onPress={reactionInit}
4040
key='message-add-reaction'
4141
testID='message-add-reaction'
42+
accessibilityRole='button'
43+
accessibilityLabel='Add reaction'
4244
style={[styles.reactionButton, { backgroundColor: themes[theme].surfaceRoom }]}
4345
hitSlop={BUTTON_HIT_SLOP}>
4446
<View style={[styles.reactionContainer, { borderColor: themes[theme].strokeLight, height }]}>
@@ -61,6 +63,9 @@ const Reaction = React.memo(({ reaction, getCustomEmoji, theme }: IMessageReacti
6163
onLongPress={onReactionLongPress}
6264
key={reaction.emoji}
6365
testID={`message-reaction-${reaction.emoji}`}
66+
accessibilityRole='button'
67+
accessibilityLabel={`${reaction.emoji}, ${reaction.usernames.length}`}
68+
accessibilityState={{ selected: reacted }}
6469
style={[styles.reactionButton, { backgroundColor: reacted ? themes[theme].surfaceNeutral : themes[theme].surfaceRoom }]}
6570
hitSlop={BUTTON_HIT_SLOP}>
6671
<View

app/containers/message/Thread.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import ThreadDetails from '../ThreadDetails';
77
import I18n from '../../i18n';
88
import { type IMessageThread } from './interfaces';
99
import { useTheme } from '../../theme';
10+
import Touchable from './Touchable';
1011

1112
const Thread = React.memo(
1213
({ msg, tcount, tlm, isThreadRoom, id }: IMessageThread) => {
1314
'use memo';
1415

1516
const { theme, colors } = useTheme();
16-
const { threadBadgeColor, toggleFollowThread, user, replies } = useContext(MessageContext);
17+
const { threadBadgeColor, toggleFollowThread, user, replies, onThreadPress } = useContext(MessageContext);
1718

1819
const backgroundColor = threadBadgeColor ? colors.badgeBackgroundLevel2 : colors.buttonBackgroundSecondaryDefault;
1920
const textColor = threadBadgeColor || theme !== 'light' ? colors.fontWhite : colors.fontPureBlack;
@@ -24,9 +25,14 @@ const Thread = React.memo(
2425

2526
return (
2627
<View style={styles.buttonContainer}>
27-
<View style={[styles.button, { backgroundColor }]} testID={`message-thread-button-${msg}`}>
28+
<Touchable
29+
onPress={onThreadPress}
30+
accessibilityRole='button'
31+
accessibilityLabel={I18n.t('View_Thread')}
32+
style={[styles.button, { backgroundColor }]}
33+
testID={`message-thread-button-${msg}`}>
2834
<Text style={[styles.buttonText, { color: textColor }]}>{I18n.t('View_Thread')}</Text>
29-
</View>
35+
</Touchable>
3036
<ThreadDetails
3137
item={{
3238
tcount,

app/containers/message/Touchable.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useContext } from 'react';
22
import { Pressable, type PressableProps } from 'react-native';
3+
import { withKeyboardFocus } from 'react-native-external-keyboard';
34

45
import MessageContext from './Context';
56

@@ -8,15 +9,23 @@ interface IProps extends PressableProps {
89
onLongPress?: () => void;
910
}
1011

12+
const KeyboardPressable = withKeyboardFocus(Pressable);
13+
1114
const RCTouchable: React.FC<IProps> = React.memo(({ children, ...props }) => {
1215
'use memo';
1316

1417
const { onLongPress } = useContext(MessageContext);
18+
const { onHoverIn, onHoverOut, ...rest } = props;
1519

1620
return (
17-
<Pressable onLongPress={onLongPress} {...props}>
21+
<KeyboardPressable
22+
focusable
23+
onLongPress={onLongPress}
24+
onHoverIn={onHoverIn || undefined}
25+
onHoverOut={onHoverOut || onLongPress}
26+
{...rest}>
1827
{children}
19-
</Pressable>
28+
</KeyboardPressable>
2029
);
2130
});
2231

0 commit comments

Comments
 (0)