Skip to content

Commit e2968cb

Browse files
Mobile: Fixes laurent22#11276: Fix new note button pushed offscreen on certain Android devices
This commit adjusts an accessibility bug workaround from (laurent22#10123), which was first present in Android v3.0.1. **Background**: React Native Paper's FAB.Group by default renders an invisible <View> that covers most/all of Joplin's UI when the FAB.Group is collapsed. This breaks TalkBack on Android's "tap to navigate" feature, which significantly impacts users that rely on TalkBack's ability to use the app. Starting from Joplin v3.0.1, the <View> added by React Native is made smaller by Joplin by adding margins above and to the left. These margins are determined by the screen size and an offset. This solution isn't perfect because it means that a small portion of the screen still blocks TalkBack's tap-to-navigate. As reported in laurent22#11276, this workaround also pushed the new note/new to-do buttons offscren. **The change** This commit changes how the FAB.Group's invisible <View> is resized. Previously it was done with margins. Now, it's done with the top/left absolute positioning properties. **Note** If [this upstream pull request](callstack/react-native-paper#4514) is merged, it should be possible to remove the workaround entirely. **Remaining steps** More testing is required before a pull request can be opened. For now, (in part because this is not a regression from v3.0), I plan to target release-3.2, rather than release-3.1, to avoid introducing additional regressions in the 3.1 version of the app. Should fix laurent22#11276, laurent22#11315.
1 parent 10583bf commit e2968cb

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

packages/app-mobile/components/buttons/FloatingActionButton.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useState, useCallback, useMemo } from 'react';
33
import { FAB, Portal } from 'react-native-paper';
44
import { _ } from '@joplin/lib/locale';
55
import { Dispatch } from 'redux';
6-
import { Platform, useWindowDimensions, View } from 'react-native';
6+
import { Platform, View, ViewStyle } from 'react-native';
77
import shim from '@joplin/lib/shim';
88
import AccessibleWebMenu from '../accessibility/AccessibleModalMenu';
99
const Icon = require('react-native-vector-icons/Ionicons').default;
@@ -71,10 +71,17 @@ const FloatingActionButton = (props: ActionButtonProps) => {
7171
// is disabled.
7272
//
7373
// See https://github.com/callstack/react-native-paper/issues/4064
74-
const windowSize = useWindowDimensions();
7574
const adjustMargins = !open && shim.mobilePlatform() === 'android';
76-
const marginTop = adjustMargins ? Math.max(0, windowSize.height - 140) : undefined;
77-
const marginStart = adjustMargins ? Math.max(0, windowSize.width - 200) : undefined;
75+
const marginStyles = useMemo((): ViewStyle => {
76+
if (!adjustMargins) {
77+
return {};
78+
}
79+
80+
return {
81+
top: undefined,
82+
left: undefined,
83+
};
84+
}, [adjustMargins]);
7885

7986
const label = props.mainButton?.label ?? _('Add new');
8087

@@ -92,7 +99,7 @@ const FloatingActionButton = (props: ActionButtonProps) => {
9299
const menuContent = <FAB.Group
93100
open={open}
94101
accessibilityLabel={label}
95-
style={{ marginStart, marginTop }}
102+
style={marginStyles}
96103
icon={ open ? openIcon : closedIcon }
97104
fabStyle={{
98105
backgroundColor: props.mainButton?.color ?? 'rgba(231,76,60,1)',

0 commit comments

Comments
 (0)