Skip to content

Commit 299c4e6

Browse files
protikbiswas100Protik Biswas
andauthored
Adding Fix for Keyboard & Narrator Focus Not in Sync (#644)
* fixing keyboard and narrator sync issue * removing unnecessary file * fixing lint error * adding review comments * adding lines to make the code as per with paper * addressing nit comments * adding chnages from pr 642 --------- Co-authored-by: Protik Biswas <protikbiswas100@microsoft.com>
1 parent 1a7d048 commit 299c4e6

1 file changed

Lines changed: 19 additions & 17 deletions

File tree

NewArch/src/App.tsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ const styles = StyleSheet.create({
4343
drawer: {
4444
backgroundColor: PlatformColor('NavigationViewDefaultPaneBackground'),
4545
height: '100%',
46-
width: 440, // Increased from default for better label fit
47-
minWidth: 440,
48-
maxWidth: 500,
4946
},
5047
drawerText: {
5148
color: PlatformColor('TextControlForeground'),
@@ -155,7 +152,7 @@ const DrawerListItem = React.forwardRef<Pressable, DrawerListItemProps>(
155152
<Text
156153
accessible={false}
157154
style={styles.drawerText}
158-
maxFontSizeMultiplier={1}
155+
maxFontSizeMultiplier={1.5}
159156
numberOfLines={1}
160157
ellipsizeMode="tail"
161158
>
@@ -204,21 +201,27 @@ const DrawerCollapsibleCategory = ({
204201
};
205202

206203
return (
207-
<View
208-
style={styles.category}
209-
accessible={true}
210-
accessibilityRole="button"
211-
accessibilityLabel={categoryLabel}
212-
onAccessibilityTap={() => setIsExpanded(!isExpanded)}>
204+
<View style={styles.category}>
213205
<Pressable
214206
style={localStyles.drawerListItem}
215207
onPress={() => onPress()}
216208
onPressIn={() => setIsPressed(true)}
217209
onPressOut={() => setIsPressed(false)}
218210
onHoverIn={() => setIsHovered(true)}
219211
onHoverOut={() => setIsHovered(false)}
220-
accessible={false}
221-
onAccessibilityTap={() => onPress()}>
212+
accessibilityRole="button"
213+
accessibilityLabel={categoryLabel}
214+
accessibilityState={{expanded: isExpanded}}
215+
accessibilityActions={[
216+
{name: isExpanded ? 'collapse' : 'expand', label: isExpanded ? 'Collapse' : 'Expand'},
217+
]}
218+
onAccessibilityAction={(event) => {
219+
if (event.nativeEvent.actionName === 'expand' || event.nativeEvent.actionName === 'collapse') {
220+
setIsExpanded(!isExpanded);
221+
}
222+
}}
223+
onAccessibilityTap={() => onPress()}
224+
focusable={true}>
222225
<View style={styles.indentContainer}>
223226
<SelectedNavigationItemPill
224227
currentRoute={currentRoute}
@@ -238,7 +241,7 @@ const DrawerCollapsibleCategory = ({
238241
</View>
239242
</Pressable>
240243
{isExpanded &&
241-
items.map((item) => (
244+
items.map((item: any) => (
242245
<DrawerListItem
243246
key={item.label}
244247
route={item.label}
@@ -299,9 +302,9 @@ function CustomDrawerContent({ navigation }: { navigation: any }) {
299302
const currentRoute = navigationState.routeNames[navigationState.index];
300303

301304
// Refs for hamburger, home and settings buttons
302-
const hamburgerRef = useRef<Pressable>(null);
303-
const homeRef = useRef<Pressable>(null);
304-
const settingsRef = useRef<Pressable>(null);
305+
const hamburgerRef = useRef<View>(null);
306+
const homeRef = useRef<View>(null);
307+
const settingsRef = useRef<View>(null);
305308

306309
// When drawer opens, focus the Home menu item
307310
useEffect(() => {
@@ -311,7 +314,6 @@ function CustomDrawerContent({ navigation }: { navigation: any }) {
311314
});
312315
}
313316
}, [isDrawerOpen]);
314-
315317
// Keyboard navigation looping handlers
316318
const onHamburgerKeyDown = (e: RNKeyboardEvent) => {
317319
if (e.nativeEvent.key === 'Tab' && e.nativeEvent.shiftKey) {

0 commit comments

Comments
 (0)